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
bug: rxLet
directive no longer renders content when Observable emits undefined
#1438
Comments
rxLet
directive does not render content when Observable emits undefined
rxLet
directive does not render content when Observable emits undefined
rxLet
directive does not render content when Observable emits undefined
rxLet
directive does not render content when Observable emits undefined
rxLet
directive no longer renders content when Observable emits undefined
Update on this. Apparently this only happens in some instances and not others. I am attempting to diagnose why and what could be different. Any advise would be greatly appreciated. I have verified that the undefined values are indeed being emitted at the time this occurs. |
Apparently this occurs when the first emitted value is ' If any other value precedes the undefined value, the template is rendered correctly. Still digging. |
Ok. I've reached the limit of my understanding / ability to debug this. I suspect this has something to do with initial change detection (inside the rxLet directive's logic to decide when the first value has been emitted) not understanding that |
hi @lincolnthree sorry for the late response and thanks for the issue. Yes, this is indeed a breaking change and was introduced with the refinement of the reactive context and template trigger api. An initial undefined value will be seen as Switching from a value to an |
Hey @hoebbelsB Thanks for the explanation. Suspense templates were indeed rendered as expected. I assume that means this issue won't be fixed/changed back to original behavior? We've relied on this handling 'undefined' as 'falsy' in... more places than I care to think about... hundreds of places...and it will be a massive effort to go in and change all of this. Any recommendations for how best to move forward other than update our code in every single instance where an undefined value might be emitted? On the topic, if this is a new feature, I'm not sure I really agree with this change. The entire point of Why does an If the goal here is to treat falsy values as Thoughts? Thanks again. |
Additional information that I think may be relevant to the discussion, and why I was having such a hard time consistently reproducing this... It seems For example:
The template will render after 3 seconds (when the final
This does appear to be the case -- If you "complicate" the scenario as seen below, the template will render when the first non-
But why should this be the case? Why should the first emission being Further adding a
I think this behavior needs to be unified. This is quite confusing/unintuitive for developers. Particularly since In the case where no If the suspense template is provided, I can see an argument for this rendering suspense if the value is tl;dr> If I'm not using suspense, all values (truthy or not, even if the first value is Thoughts again? |
hey @lincolnthree Thanks for your valuable input. Let me try to catch up.
We've decided this behavior internally. I guess we will keep it like this for now.
If you use
because
There is already an
Thanks for the intense testing, this def. sounds like something we need to take a look at.
Because we cannot distinguish between
An observable that completed once cannot emit any other value. |
Hey @hoebbelsB, thanks for reviewing. I appreciate the detailed response / breakdown. Some responses, not necessarily in any order: First, do you agree that It feels like we need a fifth conditional template in addition to Which is…. as I understand it, Essentially, we now have a scenario with In my opinion, if Once |
I don't necessarily agree. This is 100% possible. Whether or not it should be possible is a different question. First, is Second, while an If that's something that The issue here is that right now there's essentially no way to handle this consistently with how
Except that's not always true, and "most cases" isn't "all cases". Undefined can actually be set as a value! Undefined can also result from requesting data from a member/attribute/element that does not exist. It is a value! Undefined has all the problems of |
I can understand why this route was chosen, and I agree with the fact that this is complex and That said, the complexity here is indeed quite high. We have values, null values, undefined values, Observables that have emitted values, Observables that have not emitted values, Observables that have emitted So now we also have to deal with the new, special case where... " This new, opinionated definition of what This is a core issue of all languages that allow But if that's the direction |
In conslusion: Thanks again for listening. I hope you will consider letting And if this functionality is here to stay, then the docs definitely need to be updated to explain this treatment of |
Hey @lincolnthree, sorry for the late response. Currently not at home. But I've discussed this with @BioPhoton. We will work on a small refactor and try to solve your issue. Coming back next week with more details on this |
Hey @hoebbelsB no worries! Thanks for considering and I appreciate the thought. Looking forward to what you guys come up with. Happy to help as I can. |
hey @lincolnthree I sat down and tried to find a proper solution to this issue. But I first want to start by addressing your concerns here.
Yes, I agree, it is inconsistent. I hope that you'll find an answer in the end of my comment 😄
I fully agree that the current behavior is quite odd and inconsistent. But imo only the first undefined/suspense handling. I'm not 100% sure what you are saying about the complete state here. You are neither forced to wait for something to complete, nor to have a special branch for it. I think the most interesting part is about your comments about the undefined handling:
Big thx for listing the different kinds of scenarios, I appreciate that you fully understand the problem 🙏 ! These are exactly the cases we need to take a look at and where we have room for improvements. We just need to find a way to make intuitive and fun to develop with. The current implementation works like this:
all are treated specially at first run and will lead to no rendered template if no suspense template was provided. I guess here is our main issue right now. We have different choices to go from there. Still consider Option 1: consider
result in no rendered template if no suspense was provided. However, Option 2: consider only non-existing values as
result in no rendered template if no suspense was provided. However, an I personally think Option 1 is the way to go as it still allows to switch to the Let me know what you think. I'm already building a PR + unit tests for all the scenarios :) |
Finally, let me answer to another question which is kind of related to this.
You don't have to care about the suspense state if you don't want to. If you don't assign a special suspense template, the let directive will only set a special context variable. You will still be able to branch inside of your template based on the undefined value. |
Hey @hoebbelsB thanks for this! I'll try to make this reply less wordy. I'm not always great at laying things out clearly and concisely.
Can you tell me what this means, in practice? My understanding is that -- currently -- if I don't assign a suspense template, and the Observable emits (but does not complete with) |
A thought. Is there a way we could get on Discord and talk about this for a few minutes? Either I'm not understanding something, or I'm not sure my core is making sense and I want to try to clarify what I'm seeing. |
your understanding is correct. I was already talking about the situation when we've fixed the issue ^^
yes, let's have a chat tomorrow if you like |
@lincolnthree please have a look at the linked PR. Especially take a look at the following spec files, which should explain the behavior :) |
Thanks @hoebbelsB - If I'm grokking things right, this looks awesome :) I am lincolnthree num 1078 on discord if it would be convenient to chat briefly about all this. |
Description
Hey RX'ers. Potential bug with
rxLet
directive. It seems that something has changed in a recent update andundefined
values / emissions now cause the directive to fail to render the children within the element to which it is attached.Previously, the
rxLet
directive would render regardless of the value of the emission.So unless I'm missing something, this seems like a breaking change. An emission of null renders child elements just fine, which is what I would expect from either that or undefined values.
Steps to Reproduce the Issue
Essentially. If
value$
emitsundefined
, the content will not be rendered. Ifvalue$
emitsnull
, the content will be rendered as expected.Both
null
andundefined
should cause content to be rendered.Environment
Related to Other Issues
Tasks to Resolve This
Notes
The text was updated successfully, but these errors were encountered: