// New handler that creates a state machine and exposes state transitions to
// the given handler by calling its Transition method. It should be created in
// the HandlerFunc you use with metafora's Consumer.
//
// If ErrHandler is nil DefaultErrHandler will be used.
New handler that creates a state machine and exposes state transitions to
the given handler by calling its Transition method. It should be created in
the HandlerFunc you use with metafora's Consumer.

If ErrHandler is nil DefaultErrHandler will be used.
// New handler that creates a state machine and exposes state transitions to // the given handler by calling its Transition method . It should be created in // the HandlerFunc you use with metafora ' s Consumer . // // If ErrHandler is nil DefaultErrHandler will be used .
func New(task metafora.Task, h StatefulHandler, ss StateStore, cl CommandListener, e ErrHandler) metafora.Handler {
	if e == nil {
		e = DefaultErrHandler
	}
	return &stateMachine{
		task:       task,
		h:          h,
		ss:         ss,
		cl:         cl,
		errHandler: e,
		mu:         &sync.RWMutex{},
		ts:         time.Now(),
		stopL:      &sync.Mutex{},
		stopped:    make(chan bool),
	}
}
func New ( task metafora . Task , h StatefulHandler , ss StateStore , cl CommandListener , e ErrHandler ) metafora . Handler { if e == nil { e = DefaultErrHandler } return & stateMachine { task : task , h : h , ss : ss , cl : cl , errHandler : e , mu : & sync . RWMutex { } , ts : time . Now ( ) , stopL : & sync . Mutex { } , stopped : make ( chan bool ) , } }
New handler that creates a state machine and exposes state transitions to
the given handler by calling its Transition method.
New handler that creates a state machine and exposes state transitions to the given handler by calling its Transition method .