WebReflection / coincident

An Atomics based Proxy to simplify, and synchronize, Worker related tasks.
MIT License
203 stars 3 forks source link

Breaking: providing a better interrupt story #23

Closed WebReflection closed 1 year ago

WebReflection commented 1 year ago

This MR is both a revert and a followup of the previous one: https://github.com/WebReflection/coincident/pull/22

It is a breaking change because it removes the attached setInterruptHandler as that was globally shared as opposite of being related to each and every coincident world.

API Changes

The coincident(self | Worker, {...options}) options argument now accepts an interrupt field which:

/cc @hoodmane @antocuni

const { proxy } = coincident(self, {
  // as callback "handler"
  interrupt() { ... },
  // or as object ...
  interrupt: {
    delay: 42,
    handler() { ... }
  }
});
WebReflection commented 1 year ago

OK, this is ready to go as minor bump.

WebReflection commented 1 year ago

@hoodmane I am pretty happy about current state and it's worth saying the interrupt extra option makes sense and it used only from a worker as it makes no sense from the main because the main can't ever block anything from a worker as that's async anyway.

If you do find anything problematic, worse, or not working as you'd expect, please do let me know so that I can patch/fix this version instead of the globally clashing one I've pushed yesterday, thanks!

hoodmane commented 1 year ago

Looks great!