@instantdb/core
Advanced tools
Comparing version 0.6.2 to 0.6.3
@@ -77,5 +77,6 @@ import { assert } from "./utils/error"; | ||
/** | ||
* Sign in a user with a refresh token | ||
* https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* Sign in a user with a refresh toke | ||
* | ||
* @see https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* | ||
* @example | ||
@@ -82,0 +83,0 @@ * // Get the token from your backend |
@@ -131,5 +131,6 @@ "use strict"; | ||
/** | ||
* Sign in a user with a refresh token | ||
* https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* Sign in a user with a refresh toke | ||
* | ||
* @see https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* | ||
* @example | ||
@@ -136,0 +137,0 @@ * // Get the token from your backend |
@@ -77,5 +77,6 @@ import { assert } from "./utils/error"; | ||
/** | ||
* Sign in a user with a refresh token | ||
* https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* Sign in a user with a refresh toke | ||
* | ||
* @see https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* | ||
* @example | ||
@@ -82,0 +83,0 @@ * // Get the token from your backend |
@@ -112,5 +112,6 @@ import { assert } from "./utils/error"; | ||
/** | ||
* Sign in a user with a refresh token | ||
* https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* Sign in a user with a refresh toke | ||
* | ||
* @see https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* | ||
* @example | ||
@@ -117,0 +118,0 @@ * // Get the token from your backend |
@@ -10,2 +10,3 @@ export default class ReactiveDB { | ||
authCbs: any[]; | ||
attrsCbs: any[]; | ||
config: any; | ||
@@ -93,3 +94,5 @@ _persister: IndexedDBStorage; | ||
subscribeAuth(cb: any): () => void; | ||
subscribeAttrs(cb: any): () => void; | ||
notifyAuthSubs(user: any): void; | ||
notifyAttrsSubs(): void; | ||
setCurrentUser(user: any): Promise<void>; | ||
@@ -96,0 +99,0 @@ getCurrentUser(): Promise<any>; |
@@ -110,2 +110,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.authCbs = []; | ||
this.attrsCbs = []; | ||
this._reconnectTimeoutId = null; | ||
@@ -395,2 +396,3 @@ this._reconnectTimeoutMs = 0; | ||
}, {}); | ||
this.notifyAttrsSubs(); | ||
} | ||
@@ -633,5 +635,17 @@ // --------------------------- | ||
} | ||
subscribeAttrs(cb) { | ||
this.attrsCbs.push(cb); | ||
if (this.attrs) { | ||
cb(this.attrs); | ||
} | ||
return () => { | ||
this.attrsCbs = this.attrsCbs.filter((x) => x !== cb); | ||
}; | ||
} | ||
notifyAuthSubs(user) { | ||
this.authCbs.forEach((cb) => cb(user)); | ||
} | ||
notifyAttrsSubs() { | ||
this.attrsCbs.forEach((cb) => cb(this.optimisticAttrs())); | ||
} | ||
setCurrentUser(user) { | ||
@@ -638,0 +652,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -10,2 +10,3 @@ export default class ReactiveDB { | ||
authCbs: any[]; | ||
attrsCbs: any[]; | ||
config: any; | ||
@@ -93,3 +94,5 @@ _persister: IndexedDBStorage; | ||
subscribeAuth(cb: any): () => void; | ||
subscribeAttrs(cb: any): () => void; | ||
notifyAuthSubs(user: any): void; | ||
notifyAttrsSubs(): void; | ||
setCurrentUser(user: any): Promise<void>; | ||
@@ -96,0 +99,0 @@ getCurrentUser(): Promise<any>; |
@@ -138,2 +138,3 @@ "use strict"; | ||
this.authCbs = []; | ||
this.attrsCbs = []; | ||
this._reconnectTimeoutId = null; | ||
@@ -423,2 +424,3 @@ this._reconnectTimeoutMs = 0; | ||
}, {}); | ||
this.notifyAttrsSubs(); | ||
} | ||
@@ -661,5 +663,17 @@ // --------------------------- | ||
} | ||
subscribeAttrs(cb) { | ||
this.attrsCbs.push(cb); | ||
if (this.attrs) { | ||
cb(this.attrs); | ||
} | ||
return () => { | ||
this.attrsCbs = this.attrsCbs.filter((x) => x !== cb); | ||
}; | ||
} | ||
notifyAuthSubs(user) { | ||
this.authCbs.forEach((cb) => cb(user)); | ||
} | ||
notifyAttrsSubs() { | ||
this.attrsCbs.forEach((cb) => cb(this.optimisticAttrs())); | ||
} | ||
setCurrentUser(user) { | ||
@@ -666,0 +680,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@instantdb/core", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "Instant's core local abstraction", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -140,5 +140,6 @@ import { assert } from "./utils/error"; | ||
/** | ||
* Sign in a user with a refresh token | ||
* https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* Sign in a user with a refresh toke | ||
* | ||
* @see https://docs.instantdb.com/docs/backend#frontend-auth-sign-in-with-token | ||
* | ||
* @example | ||
@@ -145,0 +146,0 @@ * // Get the token from your backend |
@@ -122,2 +122,3 @@ import log from "./utils/log"; | ||
authCbs = []; | ||
attrsCbs = []; | ||
config; | ||
@@ -389,2 +390,4 @@ _persister; | ||
}, {}); | ||
this.notifyAttrsSubs(); | ||
} | ||
@@ -666,8 +669,10 @@ | ||
this._setStatus(STATUS.CLOSED); | ||
if (this._isShutdown) { | ||
log.info("[socket-close] socket has been shut down and will not reconnect"); | ||
log.info( | ||
"[socket-close] socket has been shut down and will not reconnect", | ||
); | ||
return; | ||
} | ||
log.info("[socket-close] scheduling reconnect", this._reconnectTimeoutMs); | ||
@@ -734,2 +739,14 @@ setTimeout(() => { | ||
subscribeAttrs(cb) { | ||
this.attrsCbs.push(cb); | ||
if (this.attrs) { | ||
cb(this.attrs); | ||
} | ||
return () => { | ||
this.attrsCbs = this.attrsCbs.filter((x) => x !== cb); | ||
}; | ||
} | ||
notifyAuthSubs(user) { | ||
@@ -739,2 +756,6 @@ this.authCbs.forEach((cb) => cb(user)); | ||
notifyAttrsSubs() { | ||
this.attrsCbs.forEach((cb) => cb(this.optimisticAttrs())); | ||
} | ||
async setCurrentUser(user) { | ||
@@ -741,0 +762,0 @@ const k = `currentUser`; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1362122
31229