Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.addEventListener('message', event => {
const { type, payload } = event.data;
switch (type) {
case 'INIT': {
// Initialize the snack session
snackSession = new SnackSession(payload);
snackSession.expoApiUrl = nullthrows(process.env.API_SERVER_URL);
snackSession.addStateListener(state => self.postMessage({ type: 'STATE', payload: state }));
snackSession.addPresenceListener(event =>
self.postMessage({ type: 'PRESENCE', payload: event })
);
snackSession.addErrorListener(errors => self.postMessage({ type: 'ERROR', payload: errors }));
snackSession.addLogListener(log => self.postMessage({ type: 'LOG', payload: log }));
snackSession.dependencyErrorListener = error =>
self.postMessage({ type: 'DEPENDENCY_ERROR', payload: error });
// Send the initial details
create(options) {
session = new SnackSession(options);
},