mobx-reaction-with-manual-trigger
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

mobx-reaction-with-manual-trigger

Small wrapper over MobX reaction for cases where you would like to trigger reaction manually sometimes with additional args.

        const autoMarker = '555777';
        const manualMarker = '111999';
        const autoArgs = observable({
            marker: ''
        });
 
        const disposerAndTrigger = reactionWithManualTrigger(
            (manualArg: string | undefined) => [autoArgs.marker, manualArg],
            (args) => {
                // `manualArg` arg is only passed during manual trigger 
                //...
            }
        );
 
        // this will trigger effect function with 
        // args of ('555777', undefined)
        action(() => autoArgs.marker = autoMarker)();
 
        // this will trigger effect function with 
        // args of ('555777', '111999')
        disposerAndTrigger.triggerManaully(manualMarker);

Package Sidebar

Install

npm i mobx-reaction-with-manual-trigger

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

25.2 kB

Total Files

12

Last publish

Collaborators

  • ikoshelev