Background Scripts
Last updated
Was this helpful?
Last updated
Was this helpful?
Background scripts are parts of your app that are always run as soon as the Aragon Dapp is opened. This is hugely useful if you want to keep your app up to date every time a user opens your app since you can build out your application state in the background. Furthermore, background scripts create a nice separation of concerns - your background script handles all of the state building and your app front-end is simply presentational.
First you need to instantiate an instance of the class from @aragon/api
.
Next, you need to specify that your app has a background script. In your manifest.json
file, simply specify the script
key. The value should be the path to your built background script. For example, if our built background script was located at dist/script.js
, we would specify it like so:
All of the methods are available to you. We highly recommend that you use as it handles state caching and events subscriptions for you.
If you use then state will be automatically shared with your front-end in (via ).