ealmansi/set-interval-async

Importing dependencies like an example in the readme breaks clearIntervalAsync

Closed this issue · 3 comments

The following is from the README:

// Choose one of the following flavors: dynamic, fixed, legacy.

import { setIntervalAsync } from 'set-interval-async/dynamic'
import { setIntervalAsync } from 'set-interval-async/fixed'
import { setIntervalAsync } from 'set-interval-async/legacy'
import { clearIntervalAsync } from 'set-interval-async'

When clearIntervalAsync is imported from the root of the project (as shown above) instead of from the same path as whichever "flavor" is chosen, it fails to stop the interval and throws the following error:

Invalid argument: "timer". Expected an intsance of SetIntervalAsyncTimer.

It works if both clearIntervalAsync and setIntervalAsync come from the same path. (also instance is spelled wrong in the error message :) )

Example to reproduce:
https://codesandbox.io/s/elated-wu-w6u93?file=/src/SomeComponent.js

@ealmansi

I can confirm clearIntervalAsync stopped working in my project when I updated to 2.0.1. I had to revert to 1.0.33

Same, @rbertramResi 's suggestion worked:

import { setIntervalAsync } from "set-interval-async/dynamic";
import { clearIntervalAsync } from "set-interval-async/dynamic";

@rbertramResi This is now fixed in v2.0.3 and your sample snippet taken from the README should continue to work correctly.

Thank you a lot for your report and apologies for the inconvenience.
Also, thanks a lot for chiming in @jamesst20 and @JayDouglass.