Skip to content

Commit

Permalink
fix(): send initial data message on new subscription to resources
Browse files Browse the repository at this point in the history
fixes #17
  • Loading branch information
wzr1337 committed Mar 12, 2017
1 parent 6421064 commit 52c2c5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/plugins/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface RendererElement extends Element {
class Renderers implements Resource {
private _name:string;
private _renderers:BehaviorSubject<RendererElement>[] = [];
private _change:Subject<ResourceUpdate> = new Subject();
private _change:BehaviorSubject<ResourceUpdate>;

constructor(private service:Service) {

Expand All @@ -54,7 +54,7 @@ class Renderers implements Resource {
}
});
this._renderers.push(netfluxRenderer);
this._change.next({lastUpdate: Date.now(), action: "add"});
this._change = new BehaviorSubject(<ResourceUpdate>{lastUpdate: Date.now(), action: 'init'});
}

get name():string {
Expand All @@ -65,7 +65,7 @@ class Renderers implements Resource {
return true;
};

get change():Subject<ResourceUpdate> {
get change():BehaviorSubject<ResourceUpdate> {
return this._change;
}

Expand Down Expand Up @@ -129,7 +129,7 @@ interface CollectionElement extends Element {

class Collections implements Resource {
private _collections:BehaviorSubject<CollectionElement>[] = [];
private _change:Subject<ResourceUpdate> = new Subject();
private _change:BehaviorSubject<ResourceUpdate>;

constructor(private service:Service) {

Expand All @@ -146,7 +146,7 @@ class Collections implements Resource {
}
});
this._collections.push(initialCollection);
this._change.next({lastUpdate: Date.now(), action: "add"});
this._change = new BehaviorSubject(<ResourceUpdate>{lastUpdate: Date.now(), action: 'init'});

}

Expand All @@ -162,7 +162,7 @@ class Collections implements Resource {
return true;
};

get change():Subject<ResourceUpdate> {
get change():BehaviorSubject<ResourceUpdate> {
return this._change;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/viwiPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ResourceUpdate {

export interface Resource {
name:string;
change:Subject<ResourceUpdate>;
change:BehaviorSubject<ResourceUpdate>;

//@TODO: return a promise and handle success/failure accordingly
getResource?(offset?:string|number, limit?:string|number):BehaviorSubject<Element>[]; //GET /<service>/<resource>/
Expand Down

0 comments on commit 52c2c5b

Please sign in to comment.