Coder Social home page Coder Social logo

Mixin pattern use case about vue.py HOT 7 CLOSED

stefanhoelzl avatar stefanhoelzl commented on August 29, 2024
Mixin pattern use case

from vue.py.

Comments (7)

stefanhoelzl avatar stefanhoelzl commented on August 29, 2024 1

There are no plans, in fact I do not work actively on vue.py anymore. Only take care of small bugs, if someone reports, like you did.

I guess adding MRO might not be so easy, if not impossible.
vue.py may look like Python but in the end is is only a pythonic-layer to create vue.js objects.
vue.py takes the python classes apart, and re-assembles them as vue.js objects. So in the end, it can only achieve what vue.js can do/offer.

Feel free to open tickets for issues you find, or even try to fix them. But I can't spend too much time digging into them.

from vue.py.

meteozond avatar meteozond commented on August 29, 2024 1

Thanks, looks like VueMixins are definitely MRO compatible. There was a sad typo in example preventing their usage.

I am going to play around with it.
This case is ok at first glance, and it is awesome.

class MyMixin1(VueMixin):
    @computed
    def value1(self):
        return 'value1'


class MyMixin2(VueMixin):
    @computed
    def value2(self):
        return 'value3 ' + super().value2()


class MyMixin3(MyMixin2):
    @computed
    def value3(self):
        return 'value3 ' + super().value2()


class MyMixin4(MyMixin1, MyMixin3):
    template = '<b>{{value1}}, {{value2}}, {{value3}}</b>'


class SomeComponent(VueComponent):
    mixins = [MyMixin4]

BTW. I've tried to dive into your code but, but unfortunately couldn't figure out the logic of bunch of factories and decorators. It would be nice to have some design describing docstrings.

from vue.py.

stefanhoelzl avatar stefanhoelzl commented on August 29, 2024 1

FYI: just pushed some changes to master, renaming factory.py to transformers.py, refactored it and added a bit of docstrings. Not much yet, but it may help a bit to understand the logic.

from vue.py.

meteozond avatar meteozond commented on August 29, 2024

Look like there are some other failing MRO use cases. @stefanhoelzl, is interesting for you? or may be you don't plan to make vue.py MRO compatible like vue.js does? I'm asking because MRO is a very powerful code reuse concept and could make front-end development much more easier.

from vue.py.

stefanhoelzl avatar stefanhoelzl commented on August 29, 2024

Please refer to the Mixins section in the documentation.

It re-assembles the vue.js style of Mixins instead of the pythonic way. It may be a nice to have, to detect Mixins also in the list of base classes, to have a more pythonic experience.

from vue.py.

stefanhoelzl avatar stefanhoelzl commented on August 29, 2024

In general:

  • inheritance from a single class is possible using Vue.extend (see docs)
  • inheritance from multiple classes is possible with VueMixin (as mentioned above see docs)
  • currently other uses of inheritance from multiple classes may break vue.py

from vue.py.

meteozond avatar meteozond commented on August 29, 2024

Unfortunately both Vue.extend and Vue.Mixin functionalities are very limited and require huge time and brain contribution to use it. It won't make any difference with regular JS front-end development.
That's why I was so excited with ability of using Python with its MRO in browser.
And that's why I'm wondering weather you have any plans to make vue.py MRO compatible. If so - I can collect more cases and may be write some tests. If not - I'l stop bugging you :)

from vue.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.