Open sourcec0de opened 5 months ago
@davidkpiano we ran across another issue that seems related.
It appears that calling provide
after extending with a higher-level machine function reverts to the previous machines' logic.
const machine = createMachine()
const machineWithLogging = withLogging(machine)
machineWithLogging.provide() // returns to old behavior without logging
Bug or feature request?
It would be great to have a more robust way of extending existing machines/actors.
Description:
Hello :wave: , something we noticed in the doc for higher-level-actor-logic
The spread operator is used to preserve the original actor logic. Doing this seems to drop the original prototype information so methods like
provide
go missing.(Bug) Expected result:
When using a higher-order function to extend a machine, I would expect all types and original prototype methods to pass through.
i.e this should type correctly, and the function should be present.
(Bug) Actual result:
provide
is not a function(Bug) Potential fix:
Instead of this
We ended up with this to preserve those methods. Also, shout out to @wfischer42 on our team at Discern. He's the one who implemented this fix.