atom.io 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +25 -13
- package/dist/index.d.ts +25 -13
- package/dist/index.js +37 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -22
- package/dist/index.mjs.map +1 -1
- package/json/package.json +13 -13
- package/package.json +22 -13
- package/react/dist/index.d.mts +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js +8 -4
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +8 -4
- package/react/dist/index.mjs.map +1 -1
- package/react/package.json +13 -13
- package/react-devtools/dist/index.js +693 -181
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +689 -177
- package/react-devtools/dist/index.mjs.map +1 -1
- package/react-devtools/package.json +13 -13
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime/package.json +13 -13
- package/realtime-react/dist/index.js +14 -10
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +14 -10
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-react/package.json +13 -13
- package/realtime-testing/dist/index.d.mts +1 -1
- package/realtime-testing/dist/index.d.ts +1 -1
- package/realtime-testing/dist/index.js +14 -2
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/dist/index.mjs +14 -2
- package/realtime-testing/dist/index.mjs.map +1 -1
- package/realtime-testing/package.json +13 -13
- package/src/atom.ts +2 -3
- package/src/internal/atom-internal.ts +3 -3
- package/src/internal/families-internal.ts +4 -5
- package/src/internal/index.ts +1 -0
- package/src/internal/selector/create-read-write-selector.ts +2 -2
- package/src/internal/selector/create-readonly-selector.ts +2 -2
- package/src/internal/selector-internal.ts +3 -4
- package/src/internal/store.ts +10 -10
- package/src/internal/subject.ts +24 -0
- package/src/internal/timeline-internal.ts +3 -4
- package/src/internal/transaction-internal.ts +3 -3
- package/src/react/store-context.tsx +1 -2
- package/src/react/store-hooks.ts +1 -2
- package/src/react-devtools/AtomIODevtools.tsx +2 -3
- package/src/react-devtools/StateEditor.tsx +1 -2
- package/src/react-devtools/TokenList.tsx +2 -3
- package/src/react-explorer/AtomIOExplorer.tsx +1 -2
- package/src/realtime-react/realtime-context.tsx +1 -2
- package/src/realtime-react/use-pull-family-member.ts +1 -2
- package/src/realtime-react/use-pull-family.ts +1 -2
- package/src/realtime-react/use-pull.ts +1 -2
- package/src/realtime-react/use-push.ts +1 -2
- package/src/realtime-react/use-server-action.ts +1 -2
- package/src/realtime-testing/setup-realtime-test.tsx +1 -2
- package/src/selector.ts +3 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Rx from 'rxjs';
|
|
2
1
|
import { Hamt } from 'hamt_plus';
|
|
3
2
|
import { Refinement } from 'fp-ts/lib/Refinement';
|
|
4
3
|
|
|
@@ -85,10 +84,10 @@ interface Store {
|
|
|
85
84
|
transactions: Hamt<Transaction<any>, string>;
|
|
86
85
|
valueMap: Hamt<any, string>;
|
|
87
86
|
subject: {
|
|
88
|
-
atomCreation:
|
|
89
|
-
selectorCreation:
|
|
90
|
-
transactionCreation:
|
|
91
|
-
timelineCreation:
|
|
87
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
88
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
89
|
+
transactionCreation: Subject<TransactionToken<unknown>>;
|
|
90
|
+
timelineCreation: Subject<TimelineToken>;
|
|
92
91
|
};
|
|
93
92
|
operation: OperationProgress;
|
|
94
93
|
transactionStatus: TransactionStatus<ƒn>;
|
|
@@ -127,7 +126,7 @@ type AtomFamilyOptions<T, K extends Serializable> = {
|
|
|
127
126
|
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
128
127
|
key: string;
|
|
129
128
|
type: `atom_family`;
|
|
130
|
-
subject:
|
|
129
|
+
subject: Subject<AtomToken<T>>;
|
|
131
130
|
};
|
|
132
131
|
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
133
132
|
|
|
@@ -135,7 +134,7 @@ type Atom<T> = {
|
|
|
135
134
|
key: string;
|
|
136
135
|
type: `atom`;
|
|
137
136
|
family?: FamilyMetadata;
|
|
138
|
-
subject:
|
|
137
|
+
subject: Subject<{
|
|
139
138
|
newValue: T;
|
|
140
139
|
oldValue: T;
|
|
141
140
|
}>;
|
|
@@ -229,7 +228,7 @@ type Selector<T> = {
|
|
|
229
228
|
type: `selector`;
|
|
230
229
|
family?: FamilyMetadata;
|
|
231
230
|
install: (store: Store) => void;
|
|
232
|
-
subject:
|
|
231
|
+
subject: Subject<{
|
|
233
232
|
newValue: T;
|
|
234
233
|
oldValue: T;
|
|
235
234
|
}>;
|
|
@@ -241,7 +240,7 @@ type ReadonlySelector<T> = {
|
|
|
241
240
|
type: `readonly_selector`;
|
|
242
241
|
family?: FamilyMetadata;
|
|
243
242
|
install: (store: Store) => void;
|
|
244
|
-
subject:
|
|
243
|
+
subject: Subject<{
|
|
245
244
|
newValue: T;
|
|
246
245
|
oldValue: T;
|
|
247
246
|
}>;
|
|
@@ -290,6 +289,16 @@ declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), s
|
|
|
290
289
|
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
291
290
|
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
292
291
|
|
|
292
|
+
type Subscriber<T> = (value: T) => void;
|
|
293
|
+
declare class Subject<T> {
|
|
294
|
+
subscribers: Subscriber<T>[];
|
|
295
|
+
subscribe(subscriber: Subscriber<T>): {
|
|
296
|
+
unsubscribe: () => void;
|
|
297
|
+
};
|
|
298
|
+
private unsubscribe;
|
|
299
|
+
next(value: T): void;
|
|
300
|
+
}
|
|
301
|
+
|
|
293
302
|
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
294
303
|
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
295
304
|
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
@@ -324,7 +333,7 @@ type Timeline = {
|
|
|
324
333
|
selectorTime: number | null;
|
|
325
334
|
transactionKey: string | null;
|
|
326
335
|
install: (store: Store) => void;
|
|
327
|
-
subject:
|
|
336
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
|
|
328
337
|
};
|
|
329
338
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
330
339
|
|
|
@@ -332,7 +341,7 @@ type Transaction<ƒ extends ƒn> = {
|
|
|
332
341
|
key: string;
|
|
333
342
|
type: `transaction`;
|
|
334
343
|
install: (store: Store) => void;
|
|
335
|
-
subject:
|
|
344
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
336
345
|
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
337
346
|
};
|
|
338
347
|
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
@@ -367,6 +376,8 @@ type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
|
367
376
|
type index_Selector<T> = Selector<T>;
|
|
368
377
|
type index_Store = Store;
|
|
369
378
|
type index_StoreCore = StoreCore;
|
|
379
|
+
type index_Subject<T> = Subject<T>;
|
|
380
|
+
declare const index_Subject: typeof Subject;
|
|
370
381
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
371
382
|
type index_Timeline = Timeline;
|
|
372
383
|
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
@@ -439,6 +450,7 @@ declare namespace index {
|
|
|
439
450
|
index_Selector as Selector,
|
|
440
451
|
index_Store as Store,
|
|
441
452
|
index_StoreCore as StoreCore,
|
|
453
|
+
index_Subject as Subject,
|
|
442
454
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
443
455
|
index_Timeline as Timeline,
|
|
444
456
|
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
@@ -532,12 +544,12 @@ type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
|
|
|
532
544
|
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
533
545
|
key: string;
|
|
534
546
|
type: `selector_family`;
|
|
535
|
-
subject:
|
|
547
|
+
subject: Subject<SelectorToken<T>>;
|
|
536
548
|
};
|
|
537
549
|
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
538
550
|
key: string;
|
|
539
551
|
type: `readonly_selector_family`;
|
|
540
|
-
subject:
|
|
552
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
541
553
|
};
|
|
542
554
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
543
555
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Rx from 'rxjs';
|
|
2
1
|
import { Hamt } from 'hamt_plus';
|
|
3
2
|
import { Refinement } from 'fp-ts/lib/Refinement';
|
|
4
3
|
|
|
@@ -85,10 +84,10 @@ interface Store {
|
|
|
85
84
|
transactions: Hamt<Transaction<any>, string>;
|
|
86
85
|
valueMap: Hamt<any, string>;
|
|
87
86
|
subject: {
|
|
88
|
-
atomCreation:
|
|
89
|
-
selectorCreation:
|
|
90
|
-
transactionCreation:
|
|
91
|
-
timelineCreation:
|
|
87
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
88
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
89
|
+
transactionCreation: Subject<TransactionToken<unknown>>;
|
|
90
|
+
timelineCreation: Subject<TimelineToken>;
|
|
92
91
|
};
|
|
93
92
|
operation: OperationProgress;
|
|
94
93
|
transactionStatus: TransactionStatus<ƒn>;
|
|
@@ -127,7 +126,7 @@ type AtomFamilyOptions<T, K extends Serializable> = {
|
|
|
127
126
|
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
128
127
|
key: string;
|
|
129
128
|
type: `atom_family`;
|
|
130
|
-
subject:
|
|
129
|
+
subject: Subject<AtomToken<T>>;
|
|
131
130
|
};
|
|
132
131
|
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
133
132
|
|
|
@@ -135,7 +134,7 @@ type Atom<T> = {
|
|
|
135
134
|
key: string;
|
|
136
135
|
type: `atom`;
|
|
137
136
|
family?: FamilyMetadata;
|
|
138
|
-
subject:
|
|
137
|
+
subject: Subject<{
|
|
139
138
|
newValue: T;
|
|
140
139
|
oldValue: T;
|
|
141
140
|
}>;
|
|
@@ -229,7 +228,7 @@ type Selector<T> = {
|
|
|
229
228
|
type: `selector`;
|
|
230
229
|
family?: FamilyMetadata;
|
|
231
230
|
install: (store: Store) => void;
|
|
232
|
-
subject:
|
|
231
|
+
subject: Subject<{
|
|
233
232
|
newValue: T;
|
|
234
233
|
oldValue: T;
|
|
235
234
|
}>;
|
|
@@ -241,7 +240,7 @@ type ReadonlySelector<T> = {
|
|
|
241
240
|
type: `readonly_selector`;
|
|
242
241
|
family?: FamilyMetadata;
|
|
243
242
|
install: (store: Store) => void;
|
|
244
|
-
subject:
|
|
243
|
+
subject: Subject<{
|
|
245
244
|
newValue: T;
|
|
246
245
|
oldValue: T;
|
|
247
246
|
}>;
|
|
@@ -290,6 +289,16 @@ declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), s
|
|
|
290
289
|
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
291
290
|
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
292
291
|
|
|
292
|
+
type Subscriber<T> = (value: T) => void;
|
|
293
|
+
declare class Subject<T> {
|
|
294
|
+
subscribers: Subscriber<T>[];
|
|
295
|
+
subscribe(subscriber: Subscriber<T>): {
|
|
296
|
+
unsubscribe: () => void;
|
|
297
|
+
};
|
|
298
|
+
private unsubscribe;
|
|
299
|
+
next(value: T): void;
|
|
300
|
+
}
|
|
301
|
+
|
|
293
302
|
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
294
303
|
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
295
304
|
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
@@ -324,7 +333,7 @@ type Timeline = {
|
|
|
324
333
|
selectorTime: number | null;
|
|
325
334
|
transactionKey: string | null;
|
|
326
335
|
install: (store: Store) => void;
|
|
327
|
-
subject:
|
|
336
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
|
|
328
337
|
};
|
|
329
338
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
330
339
|
|
|
@@ -332,7 +341,7 @@ type Transaction<ƒ extends ƒn> = {
|
|
|
332
341
|
key: string;
|
|
333
342
|
type: `transaction`;
|
|
334
343
|
install: (store: Store) => void;
|
|
335
|
-
subject:
|
|
344
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
336
345
|
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
337
346
|
};
|
|
338
347
|
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
@@ -367,6 +376,8 @@ type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
|
367
376
|
type index_Selector<T> = Selector<T>;
|
|
368
377
|
type index_Store = Store;
|
|
369
378
|
type index_StoreCore = StoreCore;
|
|
379
|
+
type index_Subject<T> = Subject<T>;
|
|
380
|
+
declare const index_Subject: typeof Subject;
|
|
370
381
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
371
382
|
type index_Timeline = Timeline;
|
|
372
383
|
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
@@ -439,6 +450,7 @@ declare namespace index {
|
|
|
439
450
|
index_Selector as Selector,
|
|
440
451
|
index_Store as Store,
|
|
441
452
|
index_StoreCore as StoreCore,
|
|
453
|
+
index_Subject as Subject,
|
|
442
454
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
443
455
|
index_Timeline as Timeline,
|
|
444
456
|
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
@@ -532,12 +544,12 @@ type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
|
|
|
532
544
|
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
533
545
|
key: string;
|
|
534
546
|
type: `selector_family`;
|
|
535
|
-
subject:
|
|
547
|
+
subject: Subject<SelectorToken<T>>;
|
|
536
548
|
};
|
|
537
549
|
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
538
550
|
key: string;
|
|
539
551
|
type: `readonly_selector_family`;
|
|
540
|
-
subject:
|
|
552
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
541
553
|
};
|
|
542
554
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
543
555
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
package/dist/index.js
CHANGED
|
@@ -89,6 +89,7 @@ var internal_exports = {};
|
|
|
89
89
|
__export(internal_exports, {
|
|
90
90
|
IMPLICIT: () => IMPLICIT,
|
|
91
91
|
META: () => meta_exports,
|
|
92
|
+
Subject: () => Subject,
|
|
92
93
|
TRANSACTION_PHASES: () => TRANSACTION_PHASES,
|
|
93
94
|
abortTransaction: () => abortTransaction,
|
|
94
95
|
applyTransaction: () => applyTransaction,
|
|
@@ -146,7 +147,6 @@ __export(internal_exports, {
|
|
|
146
147
|
|
|
147
148
|
// src/internal/atom-internal.ts
|
|
148
149
|
var import_hamt_plus5 = __toESM(require("hamt_plus"));
|
|
149
|
-
var Rx3 = __toESM(require("rxjs"));
|
|
150
150
|
|
|
151
151
|
// src/internal/get.ts
|
|
152
152
|
var import_hamt_plus = __toESM(require("hamt_plus"));
|
|
@@ -207,7 +207,6 @@ var import_hamt_plus3 = __toESM(require("hamt_plus"));
|
|
|
207
207
|
|
|
208
208
|
// src/internal/store.ts
|
|
209
209
|
var import_hamt_plus2 = __toESM(require("hamt_plus"));
|
|
210
|
-
var Rx = __toESM(require("rxjs"));
|
|
211
210
|
|
|
212
211
|
// ../anvl/src/function/index.ts
|
|
213
212
|
var doNothing = () => void 0;
|
|
@@ -674,10 +673,10 @@ var createStore = (name, store = null) => {
|
|
|
674
673
|
timelines: import_hamt_plus2.default.make(),
|
|
675
674
|
timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
|
|
676
675
|
subject: __spreadValues({
|
|
677
|
-
atomCreation: new
|
|
678
|
-
selectorCreation: new
|
|
679
|
-
transactionCreation: new
|
|
680
|
-
timelineCreation: new
|
|
676
|
+
atomCreation: new Subject(),
|
|
677
|
+
selectorCreation: new Subject(),
|
|
678
|
+
transactionCreation: new Subject(),
|
|
679
|
+
timelineCreation: new Subject()
|
|
681
680
|
}, store == null ? void 0 : store.subject),
|
|
682
681
|
operation: __spreadValues({
|
|
683
682
|
open: false
|
|
@@ -695,7 +694,7 @@ var createStore = (name, store = null) => {
|
|
|
695
694
|
})
|
|
696
695
|
});
|
|
697
696
|
store == null ? void 0 : store.atoms.forEach((atom2) => {
|
|
698
|
-
const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new
|
|
697
|
+
const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
|
|
699
698
|
copiedStore.atoms = import_hamt_plus2.default.set(atom2.key, copiedAtom, copiedStore.atoms);
|
|
700
699
|
});
|
|
701
700
|
store == null ? void 0 : store.readonlySelectors.forEach((selector2) => {
|
|
@@ -818,7 +817,6 @@ var hasKeyBeenUsed = (key, store = IMPLICIT.STORE) => {
|
|
|
818
817
|
|
|
819
818
|
// src/internal/transaction-internal.ts
|
|
820
819
|
var import_hamt_plus4 = __toESM(require("hamt_plus"));
|
|
821
|
-
var Rx2 = __toESM(require("rxjs"));
|
|
822
820
|
function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
823
821
|
const newTransaction = {
|
|
824
822
|
key: options.key,
|
|
@@ -843,7 +841,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
843
841
|
}
|
|
844
842
|
},
|
|
845
843
|
install: (store2) => transaction__INTERNAL(options, store2),
|
|
846
|
-
subject: new
|
|
844
|
+
subject: new Subject()
|
|
847
845
|
};
|
|
848
846
|
const core = target(store);
|
|
849
847
|
core.transactions = import_hamt_plus4.default.set(
|
|
@@ -868,7 +866,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
868
866
|
);
|
|
869
867
|
return deposit(core.atoms.get(options.key));
|
|
870
868
|
}
|
|
871
|
-
const subject = new
|
|
869
|
+
const subject = new Subject();
|
|
872
870
|
const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
873
871
|
subject,
|
|
874
872
|
type: `atom`
|
|
@@ -888,16 +886,13 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
888
886
|
return token;
|
|
889
887
|
}
|
|
890
888
|
|
|
891
|
-
// src/internal/families-internal.ts
|
|
892
|
-
var Rx4 = __toESM(require("rxjs"));
|
|
893
|
-
|
|
894
889
|
// ../anvl/src/json/index.ts
|
|
895
890
|
var import_function8 = require("fp-ts/function");
|
|
896
891
|
var stringifyJson = (json) => JSON.stringify(json);
|
|
897
892
|
|
|
898
893
|
// src/internal/families-internal.ts
|
|
899
894
|
function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
900
|
-
const subject = new
|
|
895
|
+
const subject = new Subject();
|
|
901
896
|
return Object.assign(
|
|
902
897
|
(key) => {
|
|
903
898
|
var _a;
|
|
@@ -926,7 +921,7 @@ function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
926
921
|
}
|
|
927
922
|
function readonlySelectorFamily__INTERNAL(options, store) {
|
|
928
923
|
const core = target(store);
|
|
929
|
-
const subject = new
|
|
924
|
+
const subject = new Subject();
|
|
930
925
|
return Object.assign(
|
|
931
926
|
(key) => {
|
|
932
927
|
const subKey = stringifyJson(key);
|
|
@@ -958,7 +953,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
958
953
|
return readonlySelectorFamily__INTERNAL(options, store);
|
|
959
954
|
}
|
|
960
955
|
const core = target(store);
|
|
961
|
-
const subject = new
|
|
956
|
+
const subject = new Subject();
|
|
962
957
|
return Object.assign(
|
|
963
958
|
(key) => {
|
|
964
959
|
const subKey = stringifyJson(key);
|
|
@@ -1106,10 +1101,9 @@ var import_hamt_plus9 = __toESM(require("hamt_plus"));
|
|
|
1106
1101
|
|
|
1107
1102
|
// src/internal/selector/create-read-write-selector.ts
|
|
1108
1103
|
var import_hamt_plus6 = __toESM(require("hamt_plus"));
|
|
1109
|
-
var Rx5 = __toESM(require("rxjs"));
|
|
1110
1104
|
var createReadWriteSelector = (options, family, store, core) => {
|
|
1111
1105
|
var _a;
|
|
1112
|
-
const subject = new
|
|
1106
|
+
const subject = new Subject();
|
|
1113
1107
|
const { get, set } = registerSelector(options.key, store);
|
|
1114
1108
|
const getSelf = () => {
|
|
1115
1109
|
const value = options.get({ get });
|
|
@@ -1149,7 +1143,6 @@ var createReadWriteSelector = (options, family, store, core) => {
|
|
|
1149
1143
|
|
|
1150
1144
|
// src/internal/selector/create-readonly-selector.ts
|
|
1151
1145
|
var import_hamt_plus8 = __toESM(require("hamt_plus"));
|
|
1152
|
-
var Rx6 = __toESM(require("rxjs"));
|
|
1153
1146
|
|
|
1154
1147
|
// src/internal/selector/lookup-selector-sources.ts
|
|
1155
1148
|
var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
|
|
@@ -1326,7 +1319,7 @@ var registerSelector = (selectorKey, store = IMPLICIT.STORE) => ({
|
|
|
1326
1319
|
// src/internal/selector/create-readonly-selector.ts
|
|
1327
1320
|
var createReadonlySelector = (options, family, store, core) => {
|
|
1328
1321
|
var _a;
|
|
1329
|
-
const subject = new
|
|
1322
|
+
const subject = new Subject();
|
|
1330
1323
|
const { get } = registerSelector(options.key, store);
|
|
1331
1324
|
const getSelf = () => {
|
|
1332
1325
|
const value = options.get({ get });
|
|
@@ -1370,6 +1363,29 @@ function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
1370
1363
|
return createReadWriteSelector(options, family, store, core);
|
|
1371
1364
|
}
|
|
1372
1365
|
|
|
1366
|
+
// src/internal/subject.ts
|
|
1367
|
+
var Subject = class {
|
|
1368
|
+
constructor() {
|
|
1369
|
+
this.subscribers = [];
|
|
1370
|
+
}
|
|
1371
|
+
subscribe(subscriber) {
|
|
1372
|
+
this.subscribers.push(subscriber);
|
|
1373
|
+
const unsubscribe = () => this.unsubscribe(subscriber);
|
|
1374
|
+
return { unsubscribe };
|
|
1375
|
+
}
|
|
1376
|
+
unsubscribe(subscriber) {
|
|
1377
|
+
const subscriberIndex = this.subscribers.indexOf(subscriber);
|
|
1378
|
+
if (subscriberIndex !== -1) {
|
|
1379
|
+
this.subscribers.splice(subscriberIndex, 1);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
next(value) {
|
|
1383
|
+
for (const subscriber of this.subscribers) {
|
|
1384
|
+
subscriber(value);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1373
1389
|
// src/internal/subscribe-internal.ts
|
|
1374
1390
|
var prepareUpdate = (state, store) => {
|
|
1375
1391
|
const oldValue = recallState(state, store);
|
|
@@ -1509,7 +1525,6 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1509
1525
|
|
|
1510
1526
|
// src/internal/timeline-internal.ts
|
|
1511
1527
|
var import_hamt_plus10 = __toESM(require("hamt_plus"));
|
|
1512
|
-
var Rx7 = __toESM(require("rxjs"));
|
|
1513
1528
|
|
|
1514
1529
|
// src/internal/timeline/add-atom-to-timeline.ts
|
|
1515
1530
|
var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
@@ -1657,7 +1672,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
|
|
|
1657
1672
|
}, data), {
|
|
1658
1673
|
history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
|
|
1659
1674
|
install: (store2) => timeline__INTERNAL(options, store2, tl),
|
|
1660
|
-
subject: new
|
|
1675
|
+
subject: new Subject()
|
|
1661
1676
|
});
|
|
1662
1677
|
const core = target(store);
|
|
1663
1678
|
for (const tokenOrFamily of options.atoms) {
|