RoutingInterceptor
public protocol RoutingInterceptor
RoutingInterceptor
is called before the actual navigation process happens.
e.g. user should be logged in.
NB
Interceptor is an asynchronous action. For the Router
to continue the navigation process, the completion
block of the interceptor’s
execute method MUST be called.
Otherwise, the Router
will stay in a limbo state waiting for the interceptor to finish its action.
-
Context
type associated withRoutingInterceptor
Declaration
Swift
associatedtype Context
-
prepare(with:
Default implementation) The
Router
will call this method before the navigation process. IfRoutingInterceptor
is not able to allow the navigation process to start it can stopRouter
by throwing an exception.Throws
TheRoutingError
if theRoutingInterceptor
cannot prepare itself or if the navigation process cannot start with theContext
instance provided.Default Implementation
Default implementation does nothing.
Declaration
Swift
mutating func prepare(with context: Context) throws
-
Method that will be called by
Router
to start interceptor.NB
For the
Router
to continue the navigation process, thecompletion
block of interceptor MUST be called by the implementation of this method. OtherwiseRouter
will stay in limbo waiting forRoutingInterceptor
to finish its action.Declaration
Swift
func perform(with context: Context, completion: @escaping (RoutingResult) -> Void)
-
execute(with:
Extension methodcompletion: ) Prepares the
RoutingInterceptor
and executes itDeclaration
Swift
func execute(with context: Context, completion: @escaping (RoutingResult) -> Void) throws
-
commit(with:
Extension methodcompletion: ) Prepares the
RoutingInterceptor
and performs it. Does not throw an exception.Declaration
Swift
func commit(with context: Context, completion: @escaping (RoutingResult) -> Void)
-
prepare()
Extension methodThe
Router
will call this method before the navigation process. IfRoutingInterceptor
is not able to allow the navigation process to start it can stopRouter
by throwing an exception.Throws
TheRoutingError
if theRoutingInterceptor
cannot prepare itself or if the navigation process cannot start with theContext
instance provided.Declaration
Swift
mutating func prepare() throws
-
perform(completion:
Extension method) Method that will be called by
Router
to start interceptor.NB
For the
Router
to continue the navigation process, thecompletion
block of interceptor MUST be called by the implementation of this method. OtherwiseRouter
will stay in limbo waiting forRoutingInterceptor
to finish its action.Declaration
Swift
func perform(completion: @escaping (RoutingResult) -> Void)
Parameters
completion
Completion block with a result.
-
execute(completion:
Extension method) Prepares the
RoutingInterceptor
and executes itDeclaration
Swift
func execute(completion: @escaping (RoutingResult) -> Void) throws
-
commit(completion:
Extension method) Prepares the
RoutingInterceptor
and performs it. Does not throw an exception.Declaration
Swift
func commit(completion: @escaping (RoutingResult) -> Void)
-
prepare()
Extension methodThe
Router
will call this method before the navigation process. IfRoutingInterceptor
is not able to allow the navigation process to start it can stopRouter
by throwing an exception.Throws
TheRoutingError
if theRoutingInterceptor
cannot prepare itself or if the navigation process cannot start with theContext
instance provided.Declaration
Swift
mutating func prepare() throws
-
perform(completion:
Extension method) Method that will be called by
Router
to start interceptor.NB
For the
Router
to continue the navigation process, thecompletion
block of interceptor MUST be called by the implementation of this method. OtherwiseRouter
will stay in limbo waiting forRoutingInterceptor
to finish its action.Declaration
Swift
func perform(completion: @escaping (RoutingResult) -> Void)
Parameters
completion
Completion block with a result.
-
execute(completion:
Extension method) Prepares the
RoutingInterceptor
and executes itDeclaration
Swift
func execute(completion: @escaping (RoutingResult) -> Void) throws
-
commit(completion:
Extension method) Prepares the
RoutingInterceptor
and performs it. Does not throw an exception.Declaration
Swift
func commit(completion: @escaping (RoutingResult) -> Void)