Created
December 23, 2017 02:10
-
-
Save jessemlay/ac856ebe015f408263df9a28787adf6f 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
import { HttpClient } from '@angular/common/http'; | |
import { Injectable } from '@angular/core'; | |
import { Socket } from 'ng-socket-io'; | |
import { Subject } from 'rxjs/Subject'; | |
/* | |
Generated class for the CryptoSocketProvider provider. | |
See https://angular.io/guide/dependency-injection for more info on providers | |
and Angular DI. | |
*/ | |
@Injectable() | |
export class CryptoSocketProvider { | |
constructor(private socket: Socket) { | |
socket.emit('SubAdd', { subs: ['0~Poloniex~BTC~USD'] } ); | |
let subject = new Subject(); | |
socket.on('m', function(currentData) { | |
subject.next(currentData); | |
}); | |
// use else where to subscribe | |
subject.subscribe( | |
(msg) => console.log('message received: ' + msg), | |
(err) => console.log(err), | |
() => console.log('complete') | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment