UNPKG

oidc-spa

Version:

Openidconnect client for Single Page Applications

21 lines 663 B
export function createStatefulEvt(getInitialValue) { let nextFunctions = []; let wrappedState = undefined; return { get current() { if (wrappedState === undefined) { wrappedState = [getInitialValue()]; } return wrappedState[0]; }, set current(data) { wrappedState = [data]; nextFunctions.forEach(next => next(data)); }, subscribe: (next) => { nextFunctions.push(next); return { unsubscribe: () => nextFunctions.splice(nextFunctions.indexOf(next), 1) }; } }; } //# sourceMappingURL=StatefulEvt.js.map