Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background - service #1

Open
prasadyallapu opened this issue Mar 18, 2016 · 1 comment
Open

Background - service #1

prasadyallapu opened this issue Mar 18, 2016 · 1 comment

Comments

@prasadyallapu
Copy link

Hy netmedia,

This may be unrelevant issue I am rasing.I am currently working on ionic.I was trying to do some background service.Did u figured it out.How to do in ionic.If you share details that will be helpful for me.

Thanks.

@anteburazer
Copy link
Contributor

anteburazer commented Apr 27, 2016

Hi prasadyallapu

You can use https://github.com/blittle/bridged-worker script to build a web worker and create script which will be ran in separate thread. This example is pure javascript so you'll have to adjust it for Angular apps.

In practice, create new Angular module and define worker bridge as a service: https://gist.github.com/anteburazer/ac0ef270fc91c28b5e506c16d3db1c06

This service will be used to construct you web worker functions.

Next, create your worker script which will perform some action:
https://gist.github.com/anteburazer/b5ff29cb321d6684bdbca4e0f50cf06f

This example shows how to insert some data into local database using Cordova sqlite plugin. As you can see you can inject other services as well (e.g. DataStoreService is a service which returns some data which you can iterate over and build an SQL query)

In order to run a worker you have to inject InsertDataWorke service in your file and call start function. Worker will broadcast data-inserted event which will indicate that operation is finished.

I hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants