Skip to content

Commit 28f510d

Browse files
committedNov 25, 2019
fix an issue with deep, bump version
1 parent fd8fca5 commit 28f510d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connectv/core",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "agent-based reactive programming library for typescript/javascript",
55
"keywords": [
66
"connective",

‎src/agent/keyed-deep.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ export class KeyedDeep extends SimpleDeep {
5454
let initialized = false;
5555
let _this = this;
5656

57-
this.output; // --> wire output before hand
58-
5957
let accessor: DeepAccessor = {
6058
initial: (_this._keyMap[key] || {item: undefined}).item
6159
|| (Object.values(this.value) || []).find((i: any) => this.keyfunc(i) == key),
@@ -154,6 +152,8 @@ export class KeyedDeep extends SimpleDeep {
154152

155153
protected createOutput(label: string): PinLike {
156154
if (label === 'changes') {
155+
this.output; // --> wire output before hand
156+
157157
return this.state.to(map((value: any, done: (_: ChangeMap) => void) => {
158158
const result = diff(value, this._keyMap, this.keyfunc);
159159
this._keyMap = result.newKeyMap;

‎src/agent/test/keyed-deep.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,11 @@ describe('KeyedDeep', () => {
309309

310310
s.value = [{id: 'jack', age: 24}].concat(s.value);
311311
});
312+
313+
it('should be possible to first subscribe on `.changes` and then on the state', () => {
314+
let s = new KeyedDeep(new State([]), _ => _.id);
315+
s.changes.subscribe();
316+
s.subscribe();
317+
});
312318
});
313319
});

0 commit comments

Comments
 (0)
Failed to load comments.