Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
componentWillUnmount() {
const node = this.previous;
const { $component } = this.props;
const { unmount } = $component;
if (node && isfunc(unmount)) {
unmount(node);
}
this.previous = undefined;
}
function updateData(
id: string,
state: FormDataState,
updateState: StateUpdater,
newData: TFormData,
options: InputFormOptions,
) {
const { onChange } = options;
updateState(id, state, {
currentData: newData,
changed: !compare(newData, state.initialData),
error: undefined,
});
if (isfunc(onChange)) {
Promise.resolve(onChange(newData))
.then(data => {
const updatedData = { ...newData, ...data };
updateState(id, state, {
currentData: updatedData,
changed: !compare(updatedData, state.initialData),
error: undefined,
});
})
.catch(error =>
updateState(id, state, {
error,
}),
);
}
}