Created
March 24, 2018 12:50
-
-
Save sean-nicholas/a21d3387dd62516116f71fe3c0e9b604 to your computer and use it in GitHub Desktop.
feathers-reactive with Angular Universal - data 2
This file contains hidden or 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 * as superagent from 'superagent' | |
| @Injectable() | |
| export class DataService { | |
| constructor( | |
| @Inject(PLATFORM_ID) private platformId: Object | |
| ) { | |
| if (isPlatformBrowser(this.platformId)) { | |
| const socket = io(this.BASE_URL) | |
| this.app | |
| .configure(socketio(socket)) | |
| .configure(rx({ idField: '_id' })) | |
| } else { | |
| const restClient = rest(this.BASE_URL) | |
| this.app | |
| .configure(restClient.superagent(superagent)) | |
| .configure(rxUniversal()) | |
| } | |
| } | |
| BASE_URL = 'SOME_URL' | |
| app = feathers() as Application<Services> | |
| products() { | |
| return this.app.service('products').watch().find() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment