Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

How do I create a transformer with state? #46

Open
shaunc opened this issue Apr 24, 2017 · 0 comments
Open

How do I create a transformer with state? #46

shaunc opened this issue Apr 24, 2017 · 0 comments

Comments

@shaunc
Copy link

shaunc commented Apr 24, 2017

I assume something like the following?

var MapWithState = function(f, xf) {
    return {
       "@@transducer/init": function() { 
           return {wraps: xf["@@transducer/init"](), mystate: {...}}; 
       },
       "@@transducer/result": function(result) { 
           return xf["@@transducer/result"](result.wraps); 
       },
       "@@transducer/step": function(result, input) {
           return xf["@@transducer/step"](result.wraps, f(result.mystate, input)); 
       }
    };
};
... Ie -- in result and step, I am guaranteed to be passed back whatever I created, and I guarantee that I pass back the wrapped state to the next transformer? ... However this protocol is supposed to work it should be documented....
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant