3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { PinLike } from "../pin/pin-like";
12
12
13
13
import { SimpleDeep , DeepAccessor , DeepChildFactory } from "./simple-deep" ;
14
14
import { State , EqualityFunc } from "./state" ;
15
+ import { TrackCallback } from "../shared/types" ;
15
16
16
17
17
18
/**
@@ -79,7 +80,7 @@ export class KeyedDeep extends SimpleDeep {
79
80
}
80
81
} catch ( err ) { }
81
82
} ) ,
82
- bind ( ) { return this . set . subscribe ( ) ; } ,
83
+ bind ( track : TrackCallback ) { return track ( this . set . subscribe ( ) ) ; } ,
83
84
} , this . state . compare ) ;
84
85
}
85
86
Original file line number Diff line number Diff line change 1
1
import createRandomTag from "../util/random-tag" ;
2
2
import { emission } from "../shared/emission" ;
3
+ import { TrackCallback } from "../shared/types" ;
3
4
4
5
import { map } from "../pin/map" ;
5
6
import { sink } from "../pin/sink" ;
@@ -17,7 +18,7 @@ export interface DeepAccessor {
17
18
initial : any ;
18
19
set : PinLike ;
19
20
get : PinLike ;
20
- bind ( ) : void ;
21
+ bind ( track : TrackCallback ) : void ;
21
22
}
22
23
23
24
@@ -116,7 +117,7 @@ export class SimpleDeep extends Agent {
116
117
}
117
118
} catch ( _ ) { }
118
119
} ) ,
119
- bind ( ) { return this . set . subscribe ( ) ; } ,
120
+ bind ( track : TrackCallback ) { return track ( this . set . subscribe ( ) ) ; } ,
120
121
} , this . state . compare ) ;
121
122
}
122
123
@@ -161,7 +162,7 @@ export class SimpleDeep extends Agent {
161
162
*/
162
163
bind ( ) {
163
164
if ( ! this . bound ) {
164
- if ( this . accessor ) this . accessor . bind ( ) ;
165
+ if ( this . accessor ) this . accessor . bind ( sub => this . track ( sub ) ) ;
165
166
else this . track ( this . output . subscribe ( ) ) ;
166
167
this . bound = true ;
167
168
}
Original file line number Diff line number Diff line change
1
+ import { Subscription } from "rxjs" ;
2
+
1
3
export type ErrorCallback = ( error : Error | string ) => void ;
2
4
export type ResolveCallback < T > = ( value : T ) => void ;
3
5
export type NotifyCallback = ( ) => void ;
4
6
export type ContextType = { [ keys : string ] : any } ;
7
+ export type TrackCallback = ( sub : Subscription ) => void ;
0 commit comments