Skip to content

Instantly share code, notes, and snippets.

@sean-nicholas
Created March 24, 2018 12:50
Show Gist options
  • Select an option

  • Save sean-nicholas/a21d3387dd62516116f71fe3c0e9b604 to your computer and use it in GitHub Desktop.

Select an option

Save sean-nicholas/a21d3387dd62516116f71fe3c0e9b604 to your computer and use it in GitHub Desktop.
feathers-reactive with Angular Universal - data 2
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