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

add middleware support? #52

Open
skokenes opened this issue Jul 12, 2018 · 0 comments
Open

add middleware support? #52

skokenes opened this issue Jul 12, 2018 · 0 comments

Comments

@skokenes
Copy link
Owner

Would it make sense to add basic middleware support to RxQ in the session pipeline? I'd like to keep it simple, but it'd be nice to be able to extend the behavior of what is happening that pipeline.

An example usecase: Currently I'm working on a project where due to the nature of the API calls that I make, I get two invalidation events for the objects in a row, usually within a couple milliseconds of each other. It would be great if I could debounce these at the session level for this project, rather than debouncing in other places throughout my app.

I don't want to overcomplicate things but it seems like you'd want middleware for 3 places: requests, responses, and changes.

To solve the above usecase, a faux API could be provided like:

const debounceChanges = changes$ => changes$.pipe(debounceTime(5));
const session = connectSession({
  host: "localhost",
  port: 9076,
  changesMiddleware: debounceChanges
});

This could be placed into the session where session is defined like so:

// Assume original, untouched changes stream
const changes$;

// Apply middleware to it to modify
const changesTransformed$ = changesMiddleware(changes$);

Same would apply for a requestsMiddleware and a responsesMiddleware option

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

No branches or pull requests

1 participant