Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.stream({live: true}) should provide an easy way to access reduce function from a client #8

Open
maackle opened this issue Feb 18, 2018 · 2 comments

Comments

@maackle
Copy link

maackle commented Feb 18, 2018

Since subsequent messages of a live stream are meant to be folded into the state (the first message), they are relatively useless without the original reduce function used to construct the flumeview. I don't see an easy way to get at that. For instance, if I'm using a 3rd-party lib like ssb-about that doesn't export its reducer, I'd have to copy and paste the reduce function if I wanted to use a live stream of that flumeview.

If there is already an easy way to get at the reducer, let me know. Otherwise how can we make this easy without requiring plugin authors to export their reduce function explicitly? I guess it's not so simple to "send a function over the wire" to the client...

@dominictarr
Copy link
Collaborator

correct. really, the right answer is for flumeview-reduce users to put their reduce functions in a standalone file, then load them: FlumeView(1, require('./reduce')... then the same reduce function can be brought into the browser bundle.

Fortunately there isn't a way to export a closure (given that it might have references to modules etc) as that would probably invite developers to be too clever.

@dominictarr
Copy link
Collaborator

yeah, you could just stringify a function and eval it on the client, but it would break if they had any outside references to modules. put it in it's own module is the easy way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants