API
init
This method is required to be called. If you donβt pass a config object as first argument, it will use a default config.
import { init } from 'cookie-though';
// This will show the Cookie though widget
// in case no preferences have been stored
init(config);
configure
This method allows you to reconfigure the Cookie Though widget after initial load.
import { configure } from 'cookie-though';
// This will show the Cookie though widget
// in case no preferences have been stored
configure(config);
show
Allows you to show the Cookie Though dialog. Can be useful to bind to your own logic.
import { show } from 'cookie-though';
show();
hide
Allows you to hide the Cookie Though dialog. Can be useful to bind to your own logic.
import { hide } from 'cookie-though';
hide();
getPreferences
This method allows you to retrieve the state of all the user preferences.
import { getPreferences } from 'cookie-though';
console.log('preferences', getPreferences());
onPreferencesChanged
This method allows you to listen for changes of user preferneces.
import { onPreferencesChanged } from 'cookie-though';
onPreferencesChanged((preferences)=> {
console.log('preferences', preferences);
})