quick hack, wait for ng init

feat/orm-diffs
Laurin Weger 15 hours ago
parent f45b95750a
commit 7f43ce494b
No known key found for this signature in database
GPG Key ID: 9B372BB0B792770F
  1. 2
      sdk/js/examples/multi-framework-signals/src/app/pages/index.astro
  2. 10
      sdk/js/signals/src/connector/initNg.ts
  3. 15
      sdk/js/signals/src/connector/ormConnectionHandler.ts

@ -24,7 +24,7 @@ const title = "Multi-framework app";
};
}) => {
console.log("ng web initialized. event.status, session_id:", event.status, event.session.session_id);
initNg(ng);
initNg(ng, session);
},
true,
[]

@ -2,6 +2,14 @@ import * as NG from "@ng-org/lib-wasm";
export let ng: typeof NG;
export function initNg(ngImpl: typeof NG) {
export function initNg(
ngImpl: typeof NG,
session: {
session_id: unknown;
protected_store_id: unknown;
private_store_id: unknown;
public_store_id: unknown;
}
) {
ng = ngImpl;
}

@ -74,8 +74,17 @@ export class OrmConnection<T extends BaseType> {
this.resolveReady = resolve;
});
// Establish connection to wasm land.
ng.orm_start(scope, shapeType, this.sessionId, this.onBackendMessage);
new Promise(async () => {
// Establish connection to wasm land.
await new Promise((resolve) => setTimeout(resolve, 100));
ng.orm_start(
scope,
shapeType,
this.sessionId,
this.onBackendMessage
);
});
}
/**
@ -89,7 +98,7 @@ export class OrmConnection<T extends BaseType> {
shapeType: ShapeType<T>,
scope: Scope
): OrmConnection<T> {
if (!ng) throw new Error("initNg was not called yet.");
// if (!ng) throw new Error("initNg was not called yet.");
const scopeKey = canonicalScope(scope);

Loading…
Cancel
Save