Simple plugin to deduplicate identical requests. Makes sure that when an api function is called with identical arguments in rapid succession, only one api call is made - both all calls will receive the proper result in return.
Only operates on READ operations. Argument equality is established with a simple JSON.stringify which might not be perfect, but is most likely good enough.
Can be disabled on a global, an entity or apiFn level by adding noDedup = true. Check the specs for examples.
While this is implemented as a plugin as well, this is an addition to the core functionality, as discussed with @petercrona.
This plugin sits at the very end of the plugin chain - this chain currently is [laddaCore, ...customPlugins, dedup]. This is useful because all other plugins will also benefit from this.
Let's think of the denormalization plugin as example: This plugin makes a request and does additional operations on them (potentially makes further requests, denormalizes receiving entities). With dedup sitting at the end of the chain (remember that Ladda's api object is constructed inside out, which means that the dedup plugin is the first plugin to be called when an api function is triggered), this plugin also needs to do its work once: Call is made once, everything denormalized and this result is then passed on to all identical callers.
Coverage remained the same at 100.0% when pulling a3d024a2cf13b83f19ab44012c3b74f81861f4a3 on dedup-plugin into 3b92af929aaa689d72d8581d6c9ca367a3f0e232 on plugin-api.
Coverage remained the same at 100.0% when pulling 25f8dafd0a3049e5ca45ac778291d18cdf1a5da4 on dedup-plugin into 3de6f65f22fb3670915f7d60b485d598bacf898b on plugin-api.
Coverage remained the same at 100.0% when pulling 90a8679180e1d38b491e4bfc388c05023dc87e5f on dedup-plugin into 3de6f65f22fb3670915f7d60b485d598bacf898b on plugin-api.
Coverage remained the same at 100.0% when pulling b0255c3711f65129525f5400b86b9b4be985ce2a on dedup-plugin into 19d201926fe24a067df104f5ceb1f249478a224a on plugin-api.
Simple plugin to deduplicate identical requests. Makes sure that when an api function is called with identical arguments in rapid succession, only one api call is made - both all calls will receive the proper result in return.
Only operates on
READ
operations. Argument equality is established with a simpleJSON.stringify
which might not be perfect, but is most likely good enough. Can be disabled on a global, an entity or apiFn level by addingnoDedup = true
. Check the specs for examples.While this is implemented as a plugin as well, this is an addition to the core functionality, as discussed with @petercrona. This plugin sits at the very end of the plugin chain - this chain currently is
[laddaCore, ...customPlugins, dedup]
. This is useful because all other plugins will also benefit from this.Let's think of the denormalization plugin as example: This plugin makes a request and does additional operations on them (potentially makes further requests, denormalizes receiving entities). With
dedup
sitting at the end of the chain (remember that Ladda's api object is constructed inside out, which means that the dedup plugin is the first plugin to be called when an api function is triggered), this plugin also needs to do its work once: Call is made once, everything denormalized and this result is then passed on to all identical callers.