taggedjs
Version:
tagged template reactive html
32 lines • 1.01 kB
JavaScript
export function willCallback(callback) {
return ((lastValue, utils) => {
utils.setHandler(() => {
return undefined;
});
callback(lastValue, utils.next);
});
}
/** .pipe( promise((x) => Promise.resolve(44)) ) */
export function willPromise(callback) {
return ((lastValue, utils) => {
utils.setHandler(() => {
return undefined;
}); // do nothing on initial return
const result = callback(lastValue);
result.then(x => utils.next(x));
});
}
/** .pipe( willSubscribe((x) => new ValueSubject(44)) ) */
export const willSubscribe = (callback) => {
return ((lastValue, utils) => {
utils.setHandler(() => {
return undefined;
}); // do nothing on initial return
const result = callback(lastValue);
const subscription = result.subscribe(x => {
subscription.unsubscribe();
utils.next(x);
});
});
};
//# sourceMappingURL=will.functions.js.map