From d096eed02ab4078fa5958e55b86f3f91e452a0f6 Mon Sep 17 00:00:00 2001 From: Jonathan Casarrubias Date: Thu, 15 Dec 2016 14:46:45 -0600 Subject: [PATCH] Release 2.1.0-rc.5 :rocket: - Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/27?closed=1 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/257 --- CHANGELOG.md | 6 ++++ lib/angular2/shared/models/flref.ejs | 4 ++- .../shared/services/core/realtime.ejs | 28 +++++++++++++++++-- package.json | 2 +- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38916dee..4637eac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ This file is created to keep history of the LoopBack SDK Builder, it does not consider or keeps any history of its parent module `loopback-sdk-angular`. +## Release 2.1.0-rc.5 + +- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/27?closed=1 + +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/257 + ## Release 2.1.0-rc.4 - Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/26?closed=1 diff --git a/lib/angular2/shared/models/flref.ejs b/lib/angular2/shared/models/flref.ejs index edc9cf93..98e0e012 100644 --- a/lib/angular2/shared/models/flref.ejs +++ b/lib/angular2/shared/models/flref.ejs @@ -160,7 +160,9 @@ export class FireLoopRef { let nowEvent: any = `${event}.pull.requested.${ this.id }`; this.socket.emit(`${event}.pull.request.${ this.id }`, request); function pullNow(data: any) { - that.socket.removeListener(nowEvent, pullNow); + if (that.socket.removeListener) { + that.socket.removeListener(nowEvent, pullNow); + } sbj.next(data); }; this.socket.on(nowEvent, pullNow); diff --git a/lib/angular2/shared/services/core/realtime.ejs b/lib/angular2/shared/services/core/realtime.ejs index f3fe65aa..40d84bfb 100644 --- a/lib/angular2/shared/services/core/realtime.ejs +++ b/lib/angular2/shared/services/core/realtime.ejs @@ -6,12 +6,16 @@ import { LoopBackConfig } from '../../lb.config'; import { FireLoop } from '../../models/FireLoop'; import { SocketConnections } from '../../sockets/socket.connections'; import { SDKModels } from '../custom/SDKModels'; +import { Observable } from 'rxjs/Observable'; +import { Subject } from 'rxjs/Subject'; @Injectable() export class RealTime { public IO: IO; public FireLoop: FireLoop; + private connected: boolean = false; + private socket: any; constructor( @Inject(SocketConnections) protected connections: SocketConnections, @@ -19,12 +23,30 @@ export class RealTime { @Inject(LoopBackAuth) protected auth: LoopBackAuth, @Inject(JSONSearchParams) protected searchParams: JSONSearchParams ) { - let socket: any = this.getConnection(); - this.IO = new IO(socket); - this.FireLoop = new FireLoop(socket, models); + this.socket = this.getConnection(); + this.IO = new IO(this.socket); + this.FireLoop = new FireLoop(this.socket, models); } getConnection(): void { return this.connections.getHandler(LoopBackConfig.getPath(), this.auth.getToken()); } + /** + * @method onReady + * @description + * Will trigger when FireLoop is Ready for broadcasting. + **/ + public onReady(): Observable { + let subject: Subject = new Subject(); + if (this.connected) { + subject.next(); + } else { + this.socket.on('connect', () => { + this.connected = true; + subject.next(); + }); + this.socket.on('disconnect', () => this.connected = false); + } + return subject.asObservable(); + } } diff --git a/package.json b/package.json index f4672bc2..173e3c47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mean-expert/loopback-sdk-builder", - "version": "2.1.0-rc.4", + "version": "2.1.0-rc.5", "description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack", "bin": { "lb-sdk": "bin/lb-sdk"