const customerLoader = createLoader(
(props) => props.customer,
(id, next) => {
console.log('Loading ...');
fetchCustomer(id, (err, customer) => {
if (err) return next(err);
next(null, { customer });
});
}
);
const props = { customer: '1' };
customerLoader(props, (err, state) => {
loadSecondTime();
});
function loadSecondTime() {
customerLoader(props, (err, state) => {
});
}
function loadWithDifferentProps() {
props.customer = '2';
customerLoader(props, (err, state) => {
});
}