fsm icon indicating copy to clipboard operation
fsm copied to clipboard

Should cancelFunc be public?

Open LucasChenPandaTW opened this issue 1 year ago • 1 comments

From the v1.0.0 release, the cancelFunc is introduced during FSM init with context. However, we had decoupled the callback function. When the unit test of callback may panic since it may cause the cancelFunc is not assignable. For example: create a callback function and do the unit test with a callback function. The input event may not have cancelFunc and caused panic.

P.S: Here is the event caused the panic.

Suggestion:

  1. We may need to skip the cancelFunc if it is nil to give decouple when testing the callback function here.
  2. We may need to public the cancelFunc to CancelFunc or a set function to assign the cancelFunc.

LucasChenPandaTW avatar Mar 06 '23 09:03 LucasChenPandaTW

Having the same issue, should cancelFunc be always non-nil and be a no-op by default?

mikegleasonjr avatar Feb 12 '24 13:02 mikegleasonjr