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

Computed isPending method #129

Open
littledan opened this issue Apr 3, 2024 · 8 comments
Open

Computed isPending method #129

littledan opened this issue Apr 3, 2024 · 8 comments

Comments

@littledan
Copy link
Member

@trueadm noted that it is often useful for frameworks to check whether a computed is dirty, and organize computeds in a tree, when deciding what to re-render. This subsumes certain watcher use cases. I believe this was present in an earlier draft, but we overzealously removed it when breaking out Watchers. This change is complementary to #77 and fits together well with it.

@trueadm
Copy link
Collaborator

trueadm commented Apr 3, 2024

This feature would be perfect for Svelte 5 interoperability. :)

@shaylew
Copy link
Collaborator

shaylew commented Apr 4, 2024

We may want to clarify terminology around "dirty" vs. "maybe dirty" -- some systems use both, and I'm not sure what expectations isDirty sets from just name alone. (Does it tell you that some transitive dependency changed without rerunning anything, or does it bring the dependencies up to date -- perhaps rerunning them -- and return whether any of them definitively have a newer version than the last time the consuming computed was read?)

@littledan
Copy link
Member Author

@shaylew A previous draft called this isPending. What name would you suggest?

@shaylew
Copy link
Collaborator

shaylew commented Apr 5, 2024

Hmm, the most instructive thing is probably something like mayHaveChanged, but if we have multiple things referring to dirty or pending statuses in the API it may be worth introducing the shorter term. (Naming things is hard.)

@littledan littledan changed the title Computed isDirty method Computed isPending method Apr 6, 2024
@yeomanse
Copy link
Contributor

Before I open a PR can we confirm this is the defined behavior you are referring to?
yeomanse@748a354#diff-259b63dcdb0e8ce9897c5e5e96b6d44fbbc0e7fc5031e71f9c03cab7b2f55c6dR49

OR by

frameworks to check whether a computed is dirty, and organize computeds in a tree, when deciding what to re-render. This subsumes certain watcher use cases.

means no use of watcher in which case the computed wont be live and thus need to "poll"?

@littledan
Copy link
Member Author

I don't understand the question; I think they're both talking about the same thing.

@yeomanse
Copy link
Contributor

More specifically this test
yeomanse@748a354#diff-259b63dcdb0e8ce9897c5e5e96b6d44fbbc0e7fc5031e71f9c03cab7b2f55c6dR73
Is this your expectation how it should behave? Requiring it to be watched to be able to be pending.

@dead-claudia
Copy link
Contributor

Tangential note: this is proposing exposing the "is dirty" bit I was referencing in #30 (comment).

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

5 participants