* If length of items loaded is less than `perStep`, loader * would consider itself finished and won't trigger anymore. import from 'asva-executors' /** * Constructor takes in two arguments: * * * command, which is a function that takes in * - `pointer` (position in list, OFFSET in sql), * - `perStep` (number of items per request, LIMIT in sql) * and returns promise with a specified number of items. This example is lazy loaded list of items. You may have noticed that we have Executor classes and Loader classes.Įxecutor's constructor takes in a function that returns promise, and, as a result provides better async flow control.
![isd hyperspaces into executor isd hyperspaces into executor](https://pm1.narvii.com/6708/c8da68969ace7e25f10f8d0e71dc331057a4eb44_hq.jpg)
CacheExecutor - one time requests (languages, configs, currencies), deep nested data aggregation.Executor - loaders (spinners), passing control through nested component structure.InfiniteLoader - encapsulates lazy loaded list logic.RepeatLoader - setInterval wrapped in class.DebounceLoader - provides debounce functionality.RetrierExecutor - checks condition on interval.
![isd hyperspaces into executor isd hyperspaces into executor](https://theforce.net/swtc/Pix/laserdisk/sw5/gathering11.jpg)
StatefulExecutor - stores loaded result.LadderExecutor - runs subsequent request only after previous one is finished.Executor - basic executor (is extended by all other executors).Library is armed with TypeScript declarations and tests. Expect it to be reasonably refined and well thought. This library was not born on the spot and classes were used in various applications big and small by multiple developers for more than a year. After that they're intuitive and fun to use. You can cache results, limit concurrent runs or even encapsulate into executor the logic for your lazy loaded list.Įxecutors are low-level concept and might require a bit of time to wrap your head around. Enforce specific logic for command execution.Vanilla JS solutions often involve flags and are much clunkier. For instance, executor.isRunning tells whether executor runs command or not.
![isd hyperspaces into executor isd hyperspaces into executor](https://i.stack.imgur.com/ZImOu.png)
Provide utility methods for state monitoring.They encapsulate the command, allowing it to be safely passed around without exposing its internals.InstallĬonceptually, executors are just wrappers for asynchronous commands (functions). Helper classes for your async flow control.