Giter Site home page Giter Site logo

calling events together about ferret HOT 6 OPEN

cooper avatar cooper commented on June 14, 2024
calling events together

from ferret.

Comments (6)

cooper avatar cooper commented on June 14, 2024

Evented::Object 5.62 allows multiple callbacks to have the same name. It intelligently guesses which callback you are referring to by considering the object and event name to which the callbacks were attached.

For Ferret this means that things like before, after, cancel, etc. should work as expected when calling events together. If you say before :someName but multiple events have a callback named :someName, it will refer to the one on the same event. But if :someName only exists on an event other than the one to which the callback is attached, it will refer to that one. So basically, it's smart.

Something else neat is that all :default callbacks have the same priority. So if you say before :default, the callback will be executed before all default functions involved in the multi-call.

from ferret.

cooper avatar cooper commented on June 14, 2024

so now that Event.callTogether() is functional, the next step is to create some decent-looking way to do something similar to Evented::Object's event listeners. For example, in the IRC::Bot code currently the PRIVMSG handler is manually added to each connection. Instead, there needs to be some way to make the bot "listen to" the connection.

from ferret.

cooper avatar cooper commented on June 14, 2024

OK I'm facing another issue. In Perl it is common to fire all events related to an object on that actual object. In Ferret, this would be pretty messy. It Ferret it's more common to store events in a separate object and then call them with _this set to the desired evented object.

This means that in the case of the IRC bot, we would be attaching events to the $bot.handlers and $conn.handlers objects. So the bot handlers would need to "listen to" the connection handlers. Yet, there needs to be a way to access the bot object from the callbacks attached to $bot.handlers.

from ferret.

cooper avatar cooper commented on June 14, 2024

I'm thinking the new .*addListener() special method should accept any arguments which will be supplied to the callbacks coming from a certain object. In the case of the bot, this would look something like $conn.handlers.*addListener($bot.handlers, bot: $bot).

from ferret.

cooper avatar cooper commented on June 14, 2024

Note that this would result in the listenee holding a reference to the provided arguments until .*removeListener() is called.

from ferret.

cooper avatar cooper commented on June 14, 2024

Hmmm, should adding a listener also imply it is a parent? Not sure

from ferret.

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.