Vue: Allowing for immediate option in watch option

Created on 30 Mar 2016  Â·  1Comment  Â·  Source: vuejs/vue

Vue.js version

1.0.20

Reproduction Link

https://jsfiddle.net/ardoramor/zjx57L55/

Steps to reproduce

Open console and execute the fiddle.

What is Expected?

I would expect to see the following output in the console:

new state idle
new state opening
new state buffering
new state playing
new state stopping
new state idle

What is actually happening?

I only see the initial state setting because watch is debounced:

new state idle

Applicability

I am using reactiveness in conjunction with a non-reactive player that emits events. I then rely upon state changes to facilitate UX features (hiding panels, switching streams). In one case, when one stream buffers for too long, I switch to the next one. Yet, because events of change (stop, open, buffer) are fired off so fast, Vue acts like nothing happened (because it stopped on buffer, where it started). It would be great if an option was available for advanced users to specify so that changes were propagated without debouncing.

Most helpful comment

The immediate flag is for triggering the change callback right after the initial watch call. It's not about synchronous callbacks. You can pass sync: true to get synchronous callbacks, but that's not part of the official API and it's better not to rely on it.

>All comments

The immediate flag is for triggering the change callback right after the initial watch call. It's not about synchronous callbacks. You can pass sync: true to get synchronous callbacks, but that's not part of the official API and it's better not to rely on it.

Was this page helpful?
0 / 5 - 0 ratings