Skip to content

feat(watch): new handler option immediate#6484

Merged
johnjenkins merged 6 commits intomainfrom
watch-immediate
Dec 17, 2025
Merged

feat(watch): new handler option immediate#6484
johnjenkins merged 6 commits intomainfrom
watch-immediate

Conversation

@johnjenkins
Copy link
Copy Markdown
Contributor

@johnjenkins johnjenkins commented Dec 15, 2025

What is the current behavior?

GitHub Issue Number: #6373

It's a regular developer requirement to need @Watch decorated methods to fire not only on change, but also during initialisation. At present, devs must do this manually within hooks like connectedCallback()

What is the new behavior?

By passing {immediate: true} (e.g. @Watch('propName', {immediate: true})) devs can now fire watch methods during initialisation. The method will fire for class property default values and also incoming values set via initial element attributes / props.

There's a slight difference in behaviour from dist to dist-custom-elements in that because dist-custom-elements components are native elements the watcher will fire for both default class values AND incoming values set via initial element attributes / props, whilst dist components (because they're lazily loaded) will only fire the default class value OR incoming values set via initial element attributes / props

Closes #6373

Documentation

stenciljs/site#1568

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other information

@johnjenkins johnjenkins marked this pull request as ready for review December 16, 2025 23:34
@johnjenkins johnjenkins requested a review from a team as a code owner December 16, 2025 23:34
@johnjenkins johnjenkins merged commit 7cc22f6 into main Dec 17, 2025
69 checks passed
@johnjenkins johnjenkins deleted the watch-immediate branch December 17, 2025 00:08
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.

bug: undetected initial prop value on Angular

1 participant