In my project realtime updates were working fine about a week ago. Gone back to the project today and they are no longer working. I created a gitrepo to demonstrate a similar technique to what was provided in the backendless angular blog post. I can see no reason to why these updates are not working? I continually get http requests made to https:// ** rt/lookup addresses which appear to be a fallback of some kind!
https://github.com/thedigitalpro/backendless-realtime-test
Appreciate any pointers.
Many thanks
Steven
Hi Steven
Looks like the problem is also with Angular build system,
the builder can not resolve “global” object when building a bundle for browsers that’s the reason why your app doesn’t work.
so, I found out two workarounds how to fix that:
the first, is to specify path to socket.io build for browser in tsconfig.json,
"socket.io-client": [
"./node_modules/socket.io-client/dist/socket.io"
]
just like you did it here: Backendless SDK + Angular results in compile error! - #4 by vladimir-upirov
and the other one is to add a polyfill for “global” to polyfills.ts
(window as any).global = window;
like here: javascript - Upgrading to angular-6.x gives "Uncaught ReferenceError: global is not defined" - Stack Overflow
I assume the last one is more better way
@vladimir-upirov this is extremely helpful and has solved the problem thank you. What puzzles me is that your example on your repo https://github.com/Valodya/backendless-angular works perfectly fine without any changes you have mentioned. Any ideas on this one?
Thank you once again for your help.
I guess it’s because I didn’t use “–prod” flag for building
Its odd because both projects were running locally without the --prod. Your project worked without change, other than the app id etc. It’s a mystery.
yeah, but you added the next definitions for getting “ng build --prod” working, don’t you?
"paths": {
"backendless": [
"./node_modules/backendless/lib/index.js"
],
"backendless-rt-client": [
"./node_modules/backendless-rt-client/lib/index.js"
],
"backendless-request": [
"./node_modules/backendless-request/dist/backendless-request.js"
]
}
Yes correct I just did this as a matter of course. This issue was being experienced without doing a prod build. I just simply run ng serve and experienced the problem locally.
yes, since you have re-defined paths to Backendless modules ng serve
won’t work as before, because without that Angular gets an assembled Backendless JS-SDK for browser (from node_modules/backendless/dist/backendless.js) and it works, but it doesn’t when you run ng build --prod
=)