Created
February 14, 2018 09:31
-
-
Save hpstuff/84b6ffcc6800cb990cdc2988cd2fb034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
tokens$: Observable; | |
message$: Observable; | |
constructor() { | |
this.tokens = Observable.create((observer) => { | |
this.getToken(observer); | |
this.messaging.onTokenRefresh(() => this.getToken(observer)); | |
}); | |
this.message = Objeservable.fromEvent(this.messaging, 'onMessage'); | |
} | |
getToken(observer) { | |
this.messaging.getToken() | |
.then((token) => observer.next(token)) | |
.catch((e) => throw new Error(e)); | |
} | |
} | |
constructor(private Test) { | |
} | |
method() { | |
this.subrscriber = this.Test.tokens$.subscribe((token)=> /*Send token*/, (err) => /*catch error*/); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment