Skip to content

Commit 1da90cf

Browse files
committed
Add removeAllRoutes & removeAllHandlers.
1 parent af6f2e9 commit 1da90cf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

SwiftState/StateMachine.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,15 @@ public class StateMachine<S: StateType, E: StateEventType>
453453
return false
454454
}
455455

456+
public func removeAllRoutes() -> Bool
457+
{
458+
let removingCount = self._routes.count
459+
460+
self._routes = [:]
461+
462+
return removingCount > 0
463+
}
464+
456465
//--------------------------------------------------
457466
// MARK: - Handler
458467
//--------------------------------------------------
@@ -565,6 +574,16 @@ public class StateMachine<S: StateType, E: StateEventType>
565574
return false
566575
}
567576

577+
public func removeAllHandlers() -> Bool
578+
{
579+
let removingCount = self._handlers.count + self._errorHandlers.count
580+
581+
self._handlers = [:]
582+
self._errorHandlers = []
583+
584+
return removingCount > 0
585+
}
586+
568587
// MARK: addErrorHandler
569588

570589
public func addErrorHandler(handler: Handler) -> HandlerID

0 commit comments

Comments
 (0)