Skip to content

Conversation

@manucorporat
Copy link
Contributor

@manucorporat manucorporat commented Aug 3, 2022

Breaking changes

  • useScopedStyles() -> useStylesScoped()
  • useWatch$((track) => {}) -> useWatch$(({track}) => {})
  • useClientEffect$((track) => {}) -> useClientEffect$(({track}) => {})
  • useServerMount$(): Resource<> -> useServerMount$(): void
  • useMount$(): Resource<> -> useMount$(): void

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 3, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3fed3d3
Status: ✅  Deploy successful!
Preview URL: https://7e3c3fb0.qwik-docs.pages.dev
Branch Preview URL: https://big-api-review.qwik-docs.pages.dev

View logs

@shairez
Copy link
Contributor

shairez commented Aug 3, 2022

Thanks @manucorporat !

One issue that I forgot to mention yesterday - what's the difference between useWatch and useClientEffect ?

I'm guessing useCLientEffect$ is running only on the client... but why should we use useWatch then?

@manucorporat
Copy link
Contributor Author

useWatch runs before the render, and can run in both places server and client. In the client it never runs eagerly.

We might need more docs about this

@shairez
Copy link
Contributor

shairez commented Aug 3, 2022

Thanks!

If that's the case, I think it might be less confusing to call it something similar to useClientEffect - like... useEffect ... or to change useClientEffect to useClientWatch to match them

Does it make sense?

@manucorporat
Copy link
Contributor Author

manucorporat commented Aug 3, 2022

This API has went through a lot of renamed in fact:

useWatchEffect, useEffect, and finally useClientEffect.

We want to tag as client or server APIs that only run on those platforms, for now only useClientEffect and useServerMount.

useEffect would conflict with useEffect semantics in React, and that was also a reason to avoid that name.

@manucorporat
Copy link
Contributor Author

Also, watch and effect has different semantics:

  • effect: after render
  • watch: on data change before render (giving a better time for updating data before render)

@manucorporat manucorporat merged commit dc1e2ed into main Aug 3, 2022
@manucorporat manucorporat deleted the big-api-review branch August 3, 2022 17:08
adamdbradley pushed a commit to shairez/qwik that referenced this pull request Aug 3, 2022
@manucorporat manucorporat mentioned this pull request Aug 4, 2022
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants