Comments (6)
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.
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.
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.
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.
Note that this would result in the listenee holding a reference to the provided arguments until .*removeListener()
is called.
from ferret.
Hmmm, should adding a listener also imply it is a parent? Not sure
from ferret.
Related Issues (20)
- lazy type interface prototypes sometimes added to wrong object
- Adding a list to itself causes a recursive loop when displaying it
- wide character in print with ferret -m (minify)
- multiple initializers
- change the way fail works HOT 4
- compiler shows duplicate errors for .frt and .frtdoc
- move hand-written .frt.pm files to .pm's in a separate dir from build/
- ./ferret -r FILE accepts other compiler args after it
- autoloading needs to load dependent namespaces first
- get rid of inline if
- priority hints and callback names with func keyword HOT 1
- need required value is confusing
- interactive mode
- Unexpected this variable HOT 1
- Needs documentation improvement
- 'as' keyword HOT 1
- get rid of % variables
- one-liner functions as args
- classes implemented in Perl have no version or name
- one-liner functions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ferret.