Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
falsandtru committed Jan 26, 2020
1 parent 2fb690b commit 8969f2a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
11 changes: 6 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { PartialTuple } from 'spica/type';
import { Observer } from 'spica/observation';
import { AtomicPromise } from 'spica/promise';
import { ChannelObject } from './index';
Expand All @@ -7,9 +8,9 @@ export { ChannelObject } from './index';
export class StoreChannel<K extends string, V extends StoreChannelObject<K>> {
constructor(name: string, config: StoreChannelConfig<K, V>);
readonly events: {
readonly load: Observer<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, StoreChannelEventType], StoreChannelEvent<K, V>, void>;
readonly save: Observer<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, StoreChannelEventType], StoreChannelEvent<K, V>, void>;
readonly loss: Observer<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, StoreChannelEventType], StoreChannelEvent<K, V>, void>;
readonly load: Observer<PartialTuple<[K, Extract<keyof V | '', string>, StoreChannelEventType]>, StoreChannelEvent<K, V>, void>;
readonly save: Observer<PartialTuple<[K, Extract<keyof V | '', string>, StoreChannelEventType]>, StoreChannelEvent<K, V>, void>;
readonly loss: Observer<PartialTuple<[K, Extract<keyof V | '', string>, StoreChannelEventType]>, StoreChannelEvent<K, V>, void>;
};
sync(keys: K[], cb?: (results: AtomicPromise<K>[]) => void): void;
link(key: K, age?: number): V;
Expand All @@ -30,7 +31,7 @@ export interface StoreChannelObject<K extends string> {
readonly [ChannelObject.id]: number;
readonly [ChannelObject.key]: K;
readonly [ChannelObject.date]: number;
readonly [ChannelObject.event]: Observer<[StorageChannelEventType] | [StorageChannelEventType, Extract<keyof this, string>], StorageChannelEvent<this>, void>;
readonly [ChannelObject.event]: Observer<PartialTuple<[StorageChannelEventType, Extract<keyof this, string>]>, StorageChannelEvent<this>, void>;
}
export interface StoreChannelObjectMetaData<K extends string> {
readonly id: number;
Expand Down Expand Up @@ -68,7 +69,7 @@ export interface StorageChannelConfig<V extends StorageChannelObject> {
migrate?(link: V): void;
}
export interface StorageChannelObject {
readonly [ChannelObject.event]: Observer<[StorageChannelEventType] | [StorageChannelEventType, Extract<keyof this, string>], StorageChannelEvent<this>, void>;
readonly [ChannelObject.event]: Observer<PartialTuple<[StorageChannelEventType, Extract<keyof this, string>]>, StorageChannelEvent<this>, void>;
}
export interface StorageChannelEvent<V> {
readonly type: StorageChannelEventType;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"npm-check-updates": "^4.0.1",
"power-assert": "^1.6.1",
"semver": "^7.1.1",
"spica": "0.0.313",
"spica": "0.0.314",
"tsify": "^4.0.1",
"typescript": "3.8.0-dev.20200125",
"vinyl-buffer": "^1.0.1",
Expand Down
11 changes: 6 additions & 5 deletions src/layer/data/es/store.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { PartialTuple } from 'spica/type';
import { Observation } from 'spica/observation';
import { Cancellation } from 'spica/cancellation';
import { tick } from 'spica/clock';
Expand Down Expand Up @@ -98,15 +99,15 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
}
});
}
private readonly memory = new Observation<[] | [K] | [K, keyof V | ''] | [K, keyof V | '', string] | [K, keyof V | '', string, string], void, UnstoredEventRecord<K, V> | LoadedEventRecord<K, V> | SavedEventRecord<K, V>>();
private readonly memory = new Observation<PartialTuple<[K, keyof V | '', string, string]>, void, UnstoredEventRecord<K, V> | LoadedEventRecord<K, V> | SavedEventRecord<K, V>>();
public readonly events = Object.freeze({
load: new Observation<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, EventStore.EventType], EventStore.Event<K, V>, void>(),
save: new Observation<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, EventStore.EventType], EventStore.Event<K, V>, void>(),
loss: new Observation<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, EventStore.EventType], EventStore.Event<K, V>, void>(),
load: new Observation<PartialTuple<[K, Extract<keyof V | '', string>, EventStore.EventType]>, EventStore.Event<K, V>, void>(),
save: new Observation<PartialTuple<[K, Extract<keyof V | '', string>, EventStore.EventType]>, EventStore.Event<K, V>, void>(),
loss: new Observation<PartialTuple<[K, Extract<keyof V | '', string>, EventStore.EventType]>, EventStore.Event<K, V>, void>(),
clean: new Observation<[K], boolean, void>(),
});
private readonly events_ = Object.freeze({
memory: new Observation<[K] | [K, keyof V | ''] | [K, keyof V | '', string], UnstoredEventRecord<K, V> | LoadedEventRecord<K, V> | SavedEventRecord<K, V>, void>({ limit: Infinity }),
memory: new Observation<PartialTuple<[K, keyof V | '', string]>, UnstoredEventRecord<K, V> | LoadedEventRecord<K, V> | SavedEventRecord<K, V>, void>({ limit: Infinity }),
});
private tx_: {
rw?: IDBTransaction;
Expand Down
11 changes: 6 additions & 5 deletions src/layer/domain/indexeddb/model/channel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoreChannelObject, StoreChannelObjectMetaData } from '../../../../../';
import type { PartialTuple } from 'spica/type';
import { Observation } from 'spica/observation';
import { Cancellation } from 'spica/cancellation';
import { AtomicPromise } from 'spica/promise';
Expand Down Expand Up @@ -135,14 +136,14 @@ export class ChannelStore<K extends string, V extends StoreChannelObject<K>> {
};
})(), { ignore: { delete: true } });
public readonly events_ = Object.freeze({
load: new Observation<[K] | [K, keyof V | ''] | [K, keyof V | '', ChannelStore.EventType], ChannelStore.Event<K, V>, void>(),
save: new Observation<[K] | [K, keyof V | ''] | [K, keyof V | '', ChannelStore.EventType], ChannelStore.Event<K, V>, void>(),
load: new Observation<PartialTuple<[K, keyof V | '', ChannelStore.EventType]>, ChannelStore.Event<K, V>, void>(),
save: new Observation<PartialTuple<[K, keyof V | '', ChannelStore.EventType]>, ChannelStore.Event<K, V>, void>(),
clean: new Observation<[K], boolean, void>(),
});
public readonly events = Object.freeze({
load: new Observation<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, ChannelStore.EventType], ChannelStore.Event<K, V>, void>({ limit: Infinity }),
save: new Observation<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, ChannelStore.EventType], ChannelStore.Event<K, V>, void>({ limit: Infinity }),
loss: new Observation<[K] | [K, Extract<keyof V | '', string>] | [K, Extract<keyof V | '', string>, ChannelStore.EventType], ChannelStore.Event<K, V>, void>({ limit: Infinity }),
load: new Observation<PartialTuple<[K, Extract<keyof V | '', string>, ChannelStore.EventType]>, ChannelStore.Event<K, V>, void>({ limit: Infinity }),
save: new Observation<PartialTuple<[K, Extract<keyof V | '', string>, ChannelStore.EventType]>, ChannelStore.Event<K, V>, void>({ limit: Infinity }),
loss: new Observation<PartialTuple<[K, Extract<keyof V | '', string>, ChannelStore.EventType]>, ChannelStore.Event<K, V>, void>({ limit: Infinity }),
});
public sync(keys: K[], cb: (results: AtomicPromise<K>[]) => void = noop, timeout = Infinity): void {
const cancellation = new Cancellation();
Expand Down
2 changes: 2 additions & 0 deletions src/layer/domain/indexeddb/service/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class StoreChannel<K extends string, V extends StoreChannelObject<K>> ext
if (changes.length === 0) return;
void migrate(link);
for (const { attr, oldVal } of changes) {
// @ts-ignore #31251
void cast(source[Schema.event]!)
.emit([StorageChannel.EventType.recv, attr], new StorageChannel.Event<V>(StorageChannel.EventType.recv, attr as never, memory[attr as never], oldVal as never));
}
Expand Down Expand Up @@ -97,6 +98,7 @@ export class StoreChannel<K extends string, V extends StoreChannelObject<K>> ext
() => this.factory(),
(attr, newValue, oldValue) => (
void this.add(new ChannelStore.Record<K, V>(key, { [attr]: newValue } as Partial<V>)),
// @ts-ignore #31251
void cast(this.sources.get(key)![Schema.event]!)
.emit([StorageChannel.EventType.send, attr], new StorageChannel.Event<V>(StorageChannel.EventType.send, attr as never, newValue, oldValue))),
throttle(100, () => this.has(key) && void this.log(key))))
Expand Down

0 comments on commit 8969f2a

Please sign in to comment.