Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
React.useEffect(() => {
const { connect, disconnect } = startLoadingPilets(options);
const notifier: PiletsLoading = (error, pilets, loaded) => {
initialize(!loaded, error, pilets);
};
connect(notifier);
return () => disconnect(notifier);
}, []);
// tslint:disable-next-line:no-null-keyword
ws.onmessage = ({ data }) => {
const meta = JSON.parse(data);
const getter = getDependencyResolver(globalDependencies, getDependencies);
const fetcher = (url: string) =>
fetch(url, {
method: 'GET',
cache: 'reload',
}).then(m => m.text());
loadPilet(meta, getter, fetcher).then(pilet => {
try {
const newApi = createApi(pilet);
context.injectPilet(pilet);
pilet.setup(newApi);
} catch (error) {
console.error(error);
}
});
};
ws.onmessage = ({ data }) => {
const meta = JSON.parse(data);
const getter = getDependencyResolver(globalDependencies, getDependencies);
const fetcher = (url: string) =>
fetch(url, {
method: 'GET',
cache: 'reload',
}).then(m => m.text());
loadPilet(meta, getter, fetcher).then(pilet => {
try {
const newApi = createApi(pilet);
context.injectPilet(pilet);
pilet.setup(newApi);
} catch (error) {
console.error(error);
}
});
};
function createSearchRegistration(
pilet: string,
search: SearchHandler,
settings: SearchSettings = {},
): SearchProviderRegistration {
const { onlyImmediate = false, onCancel = noop, onClear = noop } = settings;
return {
pilet,
onlyImmediate,
cancel: isfunc(onCancel) ? onCancel : noop,
clear: isfunc(onClear) ? onClear : noop,
search,
};
}
} = config;
const globalState = createGlobalState(state);
const events = createListener(globalState);
const context = createActions(globalState, events);
const createApi = defaultApiCreator(context, Array.isArray(extendApi) ? extendApi : [extendApi]);
const root = createApi({
name: 'root',
version: process.env.BUILD_PCKG_VERSION || '1.0.0',
hash: '',
});
const options = createArbiterOptions({
context,
createApi,
availablePilets,
getDependencies,
strategy: isfunc(async) ? async : async ? blazingStrategy : standardStrategy,
requestPilets,
});
if (actions) {
includeActions(context, actions);
}
return {
...events,
createApi,
context,
root,
options,
};
}
export function createFeedOptions(
id: string,
resolver: FeedResolver | FeedConnectorOptions,
): ConnectorDetails {
if (isfunc(resolver)) {
return {
id,
connect() {
return () => {};
},
initialize() {
return resolver();
},
update(data) {
return Promise.resolve(data);
},
immediately: false,
};
} else {
return {
id,
const beforeUnload = (ev: BeforeUnloadEvent) => {
const msg = isfunc(message) ? message() : message;
ev.returnValue = msg;
return msg;
};
const unlisten = onTransition && history.listen(onTransition);
componentDidUpdate() {
const { current, previous } = this;
const { $component, innerProps } = this.props;
const { update } = $component;
if (current !== previous) {
this.componentWillUnmount();
this.componentDidMount();
} else if (isfunc(update)) {
update(current, innerProps, this.context);
}
}
function createSearchRegistration(
pilet: string,
search: SearchHandler,
settings: SearchSettings = {},
): SearchProviderRegistration {
const { onlyImmediate = false, onCancel = noop, onClear = noop } = settings;
return {
pilet,
onlyImmediate,
cancel: isfunc(onCancel) ? onCancel : noop,
clear: isfunc(onClear) ? onClear : noop,
search,
};
}
componentDidMount() {
const node = this.current;
const { $component, innerProps } = this.props;
const { mount } = $component;
if (node && isfunc(mount)) {
mount(node, innerProps, this.context);
}
this.previous = node;
}