-
Notifications
You must be signed in to change notification settings - Fork 126
Errors
a-s-o edited this page Aug 16, 2015
·
3 revisions
TypeError: actionFunc.apply is not a function
This error is caused when cerebral runs into an object where a function is expected in a signal's list of actions.
// In the examples below fetchStaffList is an async action
// Both of the signal declarations below will cause this error
cerebral.signal('staffListRequested', fetchStaffList, { success: [saveStaffToCache] })
cerebral.signal('staffListRouted', ...[
checkStaffList, {
stale: [fetchStaffList, { success: [saveStaffToCache] }],
fresh: [],
fetching: []
}
]);
// Wrap async actions in an array
// |-------------------------------------------------|
// Top level async actions v v
cerebral.signal('staffListRequested', [ fetchStaffList, { success: [saveStaffToCache] } ])
cerebral.signal('staffListRouted', ...[
checkStaffList, {
// Nested async actions
// |-----------------------------------------------|
// v v
stale: [ [fetchStaffList, { success: [saveStaffToCache] }] ],
fresh: [],
fetching: []
}
]);
There is no output of action "someAction" in signal "someSignal". It should have []
This error is thrown when an action calls an output path without any arguments
// All the output paths are called without arguments,
// so they will all throw this error
function checkStaffList (input, store, output) {
const list = store.get('staffList');
if (list.isFetching) return output.fetching();
if (list.lastUpdated > (Date.now() - 10*60*1000)) {
return output.fresh();
}
store.set('staffList.isFetching', true);
output.stale();
}
checkStaffList.outputs = {
stale: {},
fresh: {},
fetching: {}
};
// Just call your outputs with an empty object
function checkStaffList (input, store, output) {
const list = store.get('staffList');
if (list.isFetching) return output.fetching({/* empty object */});
if (list.lastUpdated > (Date.now() - 10*60*1000)) {
return output.fresh({/* empty object */});
}
store.set('staffList.isFetching', true);
output.stale({/* empty object */});
}
checkStaffList.outputs = {
stale: {},
fresh: {},
fetching: {}
};