futurice / pepperoni-app-kit

Pepperoni - React Native App Starter Kit for Android and iOS
http://getpepperoni.com
MIT License
4.63k stars 645 forks source link

Global States without immutable.js ? #219

Closed ludescher closed 6 years ago

ludescher commented 7 years ago

Is there a way, to store states globally. I know you can use immutable.js, which is described in the docs, but i need to store data for just a few seconds, not persistent.

danieljharvey commented 6 years ago

Hi! If you are looking to store some data across your app and you are not concerned about immutability etc then perhaps try something like this configuration file:

https://github.com/futurice/pepperoni-app-kit/blob/master/src/utils/configuration.js

Replace let configuration = Map(); with let configuration = {} to use a regular JS object instead of the immutable Map, and then change the various functions to modify and share that instead. Said functions can then be imported wherever you need.

Hope this helps!