You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What about if the API accepted a WritableStream instance?
I'm not sure if that would be possible with this API, but if so, it seems like that could potentially make it more compatible with other streaming use cases.
This could be useful so the application doesn't need to maintain a duplicate payload state for what it's hoping to send in the beacon.
With today's API shape, if someone wanted to beacon a log of events, they'd need to:
var events = [];
// on new data
events.push({...}); // append to your events list
beacon.setData(events); // replace current beacon payload list with list+1
With updateData you wouldn't need a local (duplicate) copy of the data:
// on new data
beacon.updateData((events) => { return events.push({...}) }, []); // append to existing
Suggestion from @dominiccooney to consider an API for updating data that is more stream-like. Hopefully this captures it accurately
where
reducer(currentValue)
returns the new value and if the beacon has already been sent,initialValue
is passed in.Examples:
Replace every time
Accumulate data
// cc @nicjansma @cliffcrocker @andydavies @philipwalton @yoavweiss
The text was updated successfully, but these errors were encountered: