Erik Andershed
Erik Andershed

Reputation: 383

Download JS file and run as background services with NativeScript

Is it possible to download an JS function (JS file) and run it as an background service in NativeScript?

I have an function in JS that I like to be able to update quickly from server (if there is a bug or so). And run the script as an background service. I like to get data from health data and send push to user from the “script”.

Please help me with any ideas how to do this or point me in the right direction.

Upvotes: 0

Views: 293

Answers (1)

Manoj
Manoj

Reputation: 21908

Yes, you can. Download the JS file that has the business logic, require it with absolute path from the background service. If you are using Webpack, then you must be careful with injecting or requiring dependencies. Probably pass anything as parameter, for example if you like access to Http module inside that downloaded file (function), pass it as an argument.

Just in case if you need an example for background services, here you go.

Upvotes: 1

Related Questions