If you want to pass some value to some piece of code in JavaScript, you need to use functions.
For instance,
function createGeoLocationService(store) { let backgroundGeoLocation = new BackgroundGeoLocation() backgroundGeoLocation.configure(coordinates => { store.dispatch({ type: 'UPDATE_COORDINATES', coordinates }) }) return backgroundGeoLocation }
Now, wherever you create the repository, create this service:
let store = createStore(reducer) let backgroundGeoLocation = createGeoLocationService(store)
If you need to access them in components, you can:
- Make a singleton (yes, not what you wanted, but its a valid option for client applications)
- Skip it explicitly through the details (it can become tedious, but the most simple and clear)
- Pass it implicitly through the context (very simple, but you will be dealing with an unstable API that can be changed , so its up to you)
source share