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

Relation#subscribe is not consistent #8

Open
hecrj opened this issue Apr 21, 2015 · 4 comments
Open

Relation#subscribe is not consistent #8

hecrj opened this issue Apr 21, 2015 · 4 comments

Comments

@hecrj
Copy link
Contributor

hecrj commented Apr 21, 2015

Events received during a subscription are dispatched directly to the given block, thus they don't go through the relation pipeline. That means that mappers don't affect the received events:

rom.relation(:tasks).as(:entity).subscribe do |event|
  # event is not an entity here...
end

Is there an easy way to fix this?

@hecrj hecrj added this to the 0.1.0 milestone Apr 21, 2015
@solnic
Copy link
Member

solnic commented Apr 21, 2015

If you push this logic up to relation from dataset it should work.

@hecrj
Copy link
Contributor Author

hecrj commented Apr 21, 2015

But how do I pass the event through the mapper, if there is one? Right now I'm just yielding the event as it arrives (asynchronously), I don't see how moving the logic up to relation would help :/ Is there some way to pass the data through the Composite relation from there?

@solnic
Copy link
Member

solnic commented Apr 23, 2015

Ah, right, that's tricky. You'd have to extend Relation::Composite too. I don't think it's a good idea.

Maybe it would be a better idea to have that interface available via repository? It looks like on_event yields individual objects in a callback-style so that's not gonna work so well with ROM's data pipeline.

@hecrj
Copy link
Contributor Author

hecrj commented Apr 23, 2015

Maybe something like subscribe.each could work? subscribe could alter the behavior of the each method somehow... I'll think about it.

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

2 participants