ekazaev/route-composer

Can a custom init function be added to `NavigationControllerStep` & `TabBarControllerStep`?

wwdc14yh opened this issue · 2 comments

I have a CustomNavigationController must be call custom init function, but NavigationControllerStep does not provide custom initialization. Now i have to Now I have to re-instantiate SingleContainerStep to use the custom initialization function

Or you can set the access permission of NavigationControllerStep to open. I can override it.

Do you have any good ideas?

@wwdc14 Hi
I see your point but technically this is exactly what is SingleContainerStep for and this is expected. Because you can be not happy with the factory or a finder in NavigationControllerStep and it is absolutely normal. So SingleContainerStep step allows you to configure both of them the way you want.
I am very against any inheritance it this case, so I reserved it to be used only within the library.
If you want to be able to write your SingleContainerStep by calling just one instance in a similar manner like NavigationControllerStep - just wrap it in to a function like this:

func MyNavigationControllerStep<C>(parameters: Whatever) -> SingleContainerStep<NilFinder<MyNavigationController, C>, MyNavigationControllerFactory<MyNavigationController, C>> {
    return SingleContainerStep(finder: NilFinder(), factory: MyNavigationControllerFactory<C>(parameters: parameters))
}

and then use it like NavigationControllerStep with the same purpose:

        StepAssembly(Whatever Factory/Finder)
            .using(MyNavigationController.push())
            .from(MyNavigationControllerStep(parameters: Whatever))
            .using(GeneralAction.presentModally())
            .from(GeneralStep.current())
            .assemble()

I assume this is what you want

Awesome! thanks