stefanhoelzl/vue.py

support for custom router implementations

stefanhoelzl opened this issue · 1 comments

@vadolasi made in #12 the proposal to support custom vue router implementations.
An example how to use such a implementation with vue.js is shown here

parameter proposal

The initial proposal looks like this

class VueRouter(Wrapper):
    @classmethod
    def init_dict(cls):
        return VueRouterFactory.get_item(cls)

    def __new__(cls, vue_router_class=window.VueRouter):
        return vue_router_class.new(cls.init_dict())

using this would look like this

class Router(VueRouter):
    routes = []

App("#app", router=Router(vue_router_class=window.CustomRouter))

class attribute proposal

another proposal could look like this

class VueRouter(Wrapper):
    RouterClass = window.VueRouter

    @classmethod
    def init_dict(cls):
        return VueRouterFactory.get_item(cls)

    def __new__(cls):
        return RouterClass.new(cls.init_dict())

using this would look like this

class Router(VueRouter):
    RouterClass = window.CustomRouter
    routes = []

App("#app", router=Router())

The advantage of the class attribute proposal would be that the definition of the custom implementation and the declaration of the actual Router class is together.
This means by looking at the Router implementation it can be understood completely.
And it is also closer to the definition of other vue.py objects, where most of the functionality is described by class attributes/methods.

In the other proposal to understand the whole Router implementation someone also has to look at the App initialization.

So I would propose to implement the class attribute proposal.
@vadolasi does this work for your use case?

Yes, it would look even better this way.