GithubHelp home page GithubHelp logo

Comments (5)

 avatar commented on August 18, 2024

That's interesting - thanks. I haven't put this into Buttons already as I'm concerned as to what would happen if you need to have a pre or post action on that button that already has a pre or post action! That would then require a prePre / postPost action - gulp...

My inclination is currently to have the extended button define its own action and have that call the action function of the button that it wants to extend - a bit like calling super() in an OO language, but a bit more verbose.

from buttons.

michaeldjeffrey avatar michaeldjeffrey commented on August 18, 2024

I think if there were some pre/post events thrown around the execution of the action (Akin to Bootstraps events for modals, tooltips and the likes) that might help. The reason I didn't go with that solution is because you don't seem to have many events in the library already, and I didn't want to propose a code solution that is of a completely different style than what we're working with.

I can get behind the idea of making the extended buttons action explicitly call the action. I'm not sure of the best way to get at the actions from inside an action so it still goes through the _resolveExtends.

With the super() way, people who are trying to lazily load an action will still get a race condition where the postAction get called immediately after the action even though the action hasn't actually completed.

from buttons.

 avatar commented on August 18, 2024

The problem with pre/post events is that an async action such as loading an external script would not be complete before the action function itself is then executed. These events might be useful in some cases - when synchronous actions are all that are required, but I'm not sure they would help in this case.

from buttons.

michaeldjeffrey avatar michaeldjeffrey commented on August 18, 2024

ahh, true. I think this could work with Promises, but that's a lot of work for one case. :/

from buttons.

 avatar commented on August 18, 2024

You can now do post actions on a button with the buttons-action event - 696e161. I think that's probably as far as I want to take it at the moment. I'm not sure how useful a pre event would be, but will consider it in future if there is a solid use case for it. For now going to close.

from buttons.

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.