-
Notifications
You must be signed in to change notification settings - Fork 23
flowOf doesn't respect the passed key. #42
Comments
Just another thought about this. It seems like |
This is embarassing. Also, yeah, If you can put together a pull request, I would be glad. I am currently working on a rewrite of the engine to add more typing ;) |
Add flowOf tests to DBTests_04_Flows.
Sadly this does not work for me since I also need to get @SalomonBrys, can you have a look at @Kasheen's PR when you get the chance? By the way, I really like the library, nice work! |
@Halex193 Sorry for the slow reply on this one, been a little busy! It's been a little while since I wrote that PR, but I also remembered thinking at the time that there might be another work around when it came to deleted models which was to use the If you check out the more up to date docs on github here you might find something that helps you with regards to null models coming in through the regular flow. Sorry I haven't tested anything I've said in this message but I wanted to write this reply because I saw your comment a few days ago. |
@Kasheen thank you for taking the time to respond, it is thanks to people like you that open source projects are evolving so much! I have analyzed my needs and ended up going for a more low-level solution, using other libraries. I really like the direction that this library is going, and I would like to see it stable in the future! Maybe I will contribute myself if I get the chance. |
@Halex193 Thanks, but just to clarify incase there's any confusion - I'm not a maintainer, just a fellow user such as yourself who wrote a bug report and tried to fix it. Just thought I'd reply to your original question incase I could be of help. |
@Kasheen I know, that is why your time investment is valuable |
Summary
I realise this is currently an undocumented feature but I think I've encountered a bug with the
flowOf
function in DBImpl.Specifically line 38 doesn't take into account the key that the user passed to the function.
One would expect to only receive flow emissions for the model which relates to the passed key, but instead you get everything for that model type.
Fix Proposal
I think
trySend
atline 38
needs to be guarded withif (keyFrom(operation.model).equals(key)) { trySend(operation.model) }
Other thoughts
If you want me to provide reproducible code or a pull request for the fix I can do - or perhaps I'm misusing the feature.
It looks like the bug would affect the
stateFlowOfId
function as well because of the delegated function calls.My current workaround is just to
filter
the resulting flow and check if the model's id is the id I actually want.Ultimately it also seems useful to have a function which makes a flow that takes no key which can then be filtered differently and collected in case a user doesn't want to make a flow per id, but currently passing a key feels like it should filter.
The text was updated successfully, but these errors were encountered: