-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat(core): implement onWatch
#165
Conversation
fca71ed
to
a75b709
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.
LGTM!
@@ -129,6 +129,11 @@ export interface JSXNode<T = any> { | |||
// @public | |||
export function notifyRender(hostElement: Element): Promise<void>; | |||
|
|||
// @public | |||
export interface Observer { | |||
<T extends {}>(obj: T): T; |
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.
it would be interesting to make this more strongly typed, can we observe any kind of objects? I have an idea of how to achieve this, we can develop on a call.
anyway, good to merge for now!
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.
Yes, let's get a discussion going.
@@ -165,6 +170,12 @@ export const onUnmount$: (first: () => void) => void; | |||
// @public | |||
export function onUnmount(unmountFn: QRL<() => void>): void; | |||
|
|||
// @public | |||
export const onWatch$: (first: (obs: Observer) => unknown | (() => void)) => void; |
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.
if we can return a promise, then we should use ValueOrPromise
export const onWatch$: (first: (obs: Observer) => unknown | (() => void)) => void; | |
export const onWatch$: (first: (obs: Observer) => ValueOrPromise<unknown | (() => void)) => void>; | |
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.
I don't think we should allow a promise here. Because the whole point of the return function is to have a cleanup in case we have to call it again. If it is a promise then the cleanup function may show up way too late.
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.
gotcha! makes sense
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. |
Closes #63