Replies: 1 comment
-
Just been experimenting, and whilst I don't fully understand the JS event loop, I think I was right in the interaction between v-observe-visibility and functions that return promises. Replacing the direct call to the firebase API with:
makes the situation much better. I guess it allows the event handlers to all fire, whilst adding the API calls to the end of the queue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using v-observe-visibility to set 'read' markers on a list of Vue components. Each one registers a handler, and they are called exactly as I would expect. But, as soon as I put a firebase api call into the handler (see below), the visibility events happen in series, with a gap of
throttle
milliseconds between each one:If I replace the
fbRef.set()
call with aconsole.log()
, I can see all the events are triggered at pretty much the same time, as theq-card
elements are scrolled into view. The firebase call returns a promise, and the update happens in the background, but it seems like the event loop might be getting stalled somehow waiting for the firebase library to complete its task.Can you shed any light on why making the firebase calls has this effect, and is there a way round it with v-observe-visibility?
Tx
Beta Was this translation helpful? Give feedback.
All reactions