You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could make mux support non-standard data structures like the ones in Immutable.js by letting people write extensions. I prefer not to directly add support for Immutable.js to mux itself since everyone will want to add support for their own data structure library, so a way to write extensions seems best.
My current thinking is an API like this:
import{List,OrderedMap}from'immutable';importmux,{extendMux}from'@exponent/mux';constmuxWithImmutableSupport=extendMux(mux,async(mux,promises)=>{// The `mux` function in the formal parameters is the copy of mux that you call from// your application. So if you've extended mux many times://// const muxWithImmutableAndBinaryTreeSupport = extendMux(// extendMux(mux, handleImmutableObjects),// handleBinaryTrees,// );//// then `handleImmutableObject` should receive `muxWithImmutableAndBinaryTreeSupport`// so that if the Immutable objects contain binary trees they are recursively handled.// Should this run before or after mux has handled the standard JS data types?if(OrderedMap.isOrderedMap(promises)){letkeys=[...promises.keys()];letvalues=awaitPromise.all([...promises.values()].map(mux));returnnewOrderedMap(zip(keys,values));}// Do the same for other data types that your application uses...if(List.isList(promises)){
...
}// Don't worry about non-Immutable data typesreturnpromises;});
The text was updated successfully, but these errors were encountered:
We could make mux support non-standard data structures like the ones in Immutable.js by letting people write extensions. I prefer not to directly add support for Immutable.js to mux itself since everyone will want to add support for their own data structure library, so a way to write extensions seems best.
My current thinking is an API like this:
The text was updated successfully, but these errors were encountered: