Used to create a custom extension from scratch.
// work in progress
const MyExtension = createExtension(
'Name',
{
// options
},
(state, pond) => {
// the extension state
const { props, didSetProps } = state;
// the internal api
const {
on,
insertEntries,
removeEntries,
updateEntry,
replaceEntry,
pushTask,
abortTasks,
setEntryExtensionStatus,
getEntryExtensionStatus,
} = pond;
// called when props are updated
didSetProps((props) => {
//
});
// a task that needs to run on an entry, these are queued, so only run if other tasks finish successfully
function taskCustomJob(entry) {
//
}
// called when an entry is updated
function handleUpdateEntry(entry) {
//
}
// called when the entry list is updated
function handleUpdateEntries(entries) {
//
}
// when the entry list is updated we call handleUpdateEntries
const unsubUpdateEntryList = on('updateEntries', debounce(handleUpdateEntries));
// when an entry is updated we call handleUpdateEntry
const unsubUpdateEntry = on('updateEntry', handleUpdateEntry);
return {
destroy: () => {
unsubUpdateEntry();
unsubUpdateEntryList();
},
};
}
);