-
Notifications
You must be signed in to change notification settings - Fork 28
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 support for binding textures directly from a TextureSequence
#1770
Conversation
Something I realized while applying pattern matching to the other path is that these two paths handle getting the texture ID at different times. (My path reads it in the Not entirely sure if that has any observable behavior differences. My gut says that my implementation is probably slightly better since consumers of |
This can be an important point, the main difference is that the timing of the code outside the closure can be controlled by the input sequence, whereas running code inside the closure we cannot make any assumptions about when exactly it will be run. This can be important when Because of this detail, if anything I would tend to err on the side of capturing outside the closure. The easiest way to do this would be to change the signature of the delegate to receive the captured nullable, e.g.: IObservable<TSource> Process<TSource>(IObservable<TSource> source, Action<int?, TSource> update) |
That's sensible. Looking at it closer though, I ended up refactoring the function to take a getter for the texture ID instead of an update function. Your suggestion would've only unified the capture of It's a bit more of a change, but I think it better matches the existing behavior exactly in both cases. |
Revisiting this again with a fresh mind, I realized we were both getting a little caught up on the The latest iteration does away with the delegate entirely and instead has This technically makes the The diff looks like I changed documentation but I actually just moved the body of the private As an aside, is it desirable that we just nothing when there's no texture? Seems like it should maybe be an error. |
51a8822
to
5f8df5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion in my previous comment, it took me a while to fully reload the context of this operator and while doing several edits to the comment I probably failed to explain myself correctly.
I think this will be the last iteration and happy to go back to having everything in one method. This is basically the same as your previous proposal except introducing an extra local instead of renaming the cache variable.
Indeed this operator is surprisingly nuanced, and I learned several things from this review so definitely worthwhile!
Fixes #1645