corvée(dépendances) ajoute Carbon Fields

This commit is contained in:
gcch 2024-08-09 18:45:01 +02:00
commit 62368587e5
459 changed files with 72750 additions and 26 deletions

View file

@ -0,0 +1,23 @@
/**
* External dependencies.
*/
import create from 'callbag-create';
/**
* Callbag source factory from `addHandler` and `removeHandler` pair.
*
* @see https://github.com/Andarist/callbag-from-event-pattern
* @param {Function} addHandler
* @param {Function} removeHandler
* @param {Function} argsTransformer
* @return {Function}
*/
export default function fromEventPattern( addHandler, removeHandler, argsTransformer = ( ...args ) => args ) {
return create( ( sink ) => {
const handler = ( ...args ) => sink( 1, argsTransformer( ...args ) );
addHandler( handler );
return () => removeHandler( handler );
} );
}