Skip to content

Commit

Permalink
Let liveQuery() be type-wise compable with RxJS (#1417)
Browse files Browse the repository at this point in the history
* Let liveQuery() be type-wise compable with RxJS

* Flag for dts-bundle-generator to inline global
declarations.
  • Loading branch information
dfahlander committed Oct 27, 2021
1 parent 46a430f commit c0875ef
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -59,7 +59,7 @@
"node ../tools/replaceVersionAndDate.js ../dist/dexie.js",
"node ../tools/replaceVersionAndDate.js ../dist/dexie.mjs",
"node ../tools/replaceVersionAndDate.js ../dist/modern/dexie.mjs",
"dts-bundle-generator --inline-declare-externals -o ../dist/dexie.d.ts public/index.d.ts",
"dts-bundle-generator --inline-declare-global --inline-declare-externals -o ../dist/dexie.d.ts public/index.d.ts",
"node ../tools/prepend.js ../dist/dexie.d.ts ../tools/build-configs/banner.txt",
"node ../tools/replaceVersionAndDate.js ../dist/dexie.d.ts"
],
Expand Down Expand Up @@ -94,7 +94,7 @@
},
"homepage": "https://dexie.org",
"devDependencies": {
"dts-bundle-generator": "^5.7.0",
"dts-bundle-generator": "^5.9.0",
"just-build": "^0.9.19",
"karma": "^6.1.1",
"karma-browserstack-launcher": "^1.5.2",
Expand Down
6 changes: 3 additions & 3 deletions src/classes/observable/observable.ts
Expand Up @@ -4,10 +4,10 @@ import {
Subscription,
} from "../../public/types/observable";

const symbolObservable =
const symbolObservable: typeof Symbol.observable =
typeof Symbol !== "undefined" && "observable" in Symbol
? Symbol["observable"]
: "@@observable";
? Symbol.observable
: "@@observable" as any;

export class Observable<T> implements IObservable<T> {
private _subscribe: (observer: Observer<T>) => Subscription;
Expand Down
6 changes: 6 additions & 0 deletions src/public/types/observable.d.ts
@@ -1,12 +1,18 @@
// There typings are extracted from https://github.com/tc39/proposal-observable

declare global {
interface SymbolConstructor {
readonly observable: symbol;
}
}
export interface Observable<T = any> {
subscribe(
onNext?: ((value: T) => void) | null,
onError?: ((error: any) => void) | null,
onComplete?: (() => void) | null
): Subscription;
subscribe(observer?: Observer<T> | null): Subscription;
[Symbol.observable]: () => Observable<T>;
}

export interface Subscription {
Expand Down

0 comments on commit c0875ef

Please sign in to comment.