dexie-react-hooks
Version:
React hooks for reactive data fetching using Dexie.js
18 lines (17 loc) • 389 B
text/typescript
export class BinarySemaphore {
constructor() {
this.init();
}
post: () => void;
then: (onSuccess: (val: any) => void, onError: (err: any) => void) => void;
reset() {
this.post();
this.init();
}
private init() {
const promise = new Promise<void>((resolve) => {
this.post = resolve as () => void;
});
this.then = promise.then.bind(promise);
}
}