I'm trying to use Stream with Angular 7, however I am getting the following error.
ReferenceError: global is not defined ReferenceError: global is not defined at Object../node_modules/faye/src/util/browser/event.js (event.js:45) at webpack_require (bootstrap:83) at Object../node_modules/faye/src/protocol/client.js (client.js:8) at webpack_require (bootstrap:83) at Object../node_modules/faye/src/faye_browser.js (faye_browser.js:9) at webpack_require (bootstrap:83) at Object../node_modules/getstream/lib/lib/client.js (client.js:25) at webpack_require (bootstrap:83) at Object../node_modules/getstream/lib/getstream.js (getstream.js:6) at webpack_require (bootstrap:83) at resolvePromise (zone.js:814) at resolvePromise (zone.js:771) at zone.js:873 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:16147) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595)
I am using the package "getstream" from npm version 4.1.0.
Here is a snippet of code and how I am referencing it.
import { Injectable } from '@angular/core';
import { Constants } from './../constants';
import * as stream from 'getstream';
@Injectable({
providedIn: 'root'
})
export class ActivityService {
userToken: string;
streamClient: stream.Client;
constructor(public azureService: AzureService) {
console.log("Activity Service");
}
async initializeClient() {
try {
await this.getUserToken();
if (this.userToken) {
this.streamClient = await stream.connect(Constants.streamKey, this.userToken, Constants.streamAppId);
}
}
catch (error) {
console.log('Error creating stream client - ', error);
throw error;
}
}
I've tried declaring global but I am not sure what else to try. What's the proper way to import and use Stream in this case?