Welcome Guest, Not a member yet? Register   Sign In
Events Library (v0.5)
#11

[eluser]Milos Dakic[/eluser]
Just updated the library to version 0.2 with the fix proposed by gazza. Updated initial post.
#12

[eluser]tonydewan[/eluser]
This is nice.
#13

[eluser]Milos Dakic[/eluser]
Would anyone be interested in autoloading events?

I'm thinking along the lines of something like:

Code:
$autoload['events'] = array(
array('event_name','callback_function'[,'module'])
...
);

As per usual you will be able to specify multiple everything when doing this.
#14

[eluser]Milos Dakic[/eluser]
New version now available. Version 0.3 (beta)

Nothing big was added apart from the autoloading of events.

You can do so by adding a events.php file to your application/config folder.

Code:
$events['autoload'] = array('event' => 'event','callback' => 'callback' [, 'module' => 'module']);

You can as always pass multiple values for the event and callback functions.

Code:
$events['autoload'] = array('event' => array('event_one','event_two'),'callback' => array('callback_one','callback_two'));

Hope someone finds this update useful. And please if possible provide feedback Smile
#15

[eluser]ReLexEd[/eluser]
Like what you've done sofar, and will be keeping tabs on progress for this one... Wink

I'm in the process of convincing our most important client to have us refactor the application that has been developed for his company over the last couple of years, which has become quite a mess of spaghetti-code....

I'm already sure that this will make it's way in!


Since I havent spent to much time with the library, I'm not realy sure if this is the kind of feedback your looking for, but here goes:


While I was following your example in the documentation, I noticed that the event_handle_on_subscribe_new-function was supposed to get it's parameters handed down in an array, but over here I just got the first element as a string.
When I dove into events.php I found after a little tinkering that changing the following line:
Code:
$callback_result = call_user_func_array($callback, $params);
to:
Code:
$callback_result = call_user_func_array($callback, array($params));
Would give the correct parameters in an array...

I'm not really sure if I was doing something wrong, or if the example was using untested code Wink


Also, to better allow devvers not using patterns (;-)) to better grasp the concept, you might want to consider using the correct scope in the event-functions. (I had to use get_instance to get the CI-object, and load the array-helper and email-library...

No biggies, but it might save one or two others 15 to 20 minutes figuring out what this little gem does....

Kudo's nevertheless for a nice library!
#16

[eluser]tdktank59[/eluser]
Look good,

Ill check it out when I get a chance. Ill probably load it into a production environment once some more of the kinks are worked out!
#17

[eluser]Milos Dakic[/eluser]
[quote author="ReLexEd" date="1235525702"]Like what you've done sofar, and will be keeping tabs on progress for this one... Wink

I'm in the process of convincing our most important client to have us refactor the application that has been developed for his company over the last couple of years, which has become quite a mess of spaghetti-code....

I'm already sure that this will make it's way in!
[/quote]

Thank you very much! :]

[quote author="ReLexEd" date="1235525702"]
While I was following your example in the documentation, I noticed that the event_handle_on_subscribe_new-function was supposed to get it's parameters handed down in an array, but over here I just got the first element as a string.
When I dove into events.php I found after a little tinkering that changing the following line:
Code:
$callback_result = call_user_func_array($callback, $params);
to:
Code:
$callback_result = call_user_func_array($callback, array($params));
Would give the correct parameters in an array...
[/quote]

Ok, well first bug! :] It should actually be
Code:
$callback_result = call_user_func($callback,$params);

So that when you do this:
Code:
$this->events->register('on_system_load','on_system_load');
$params = array('value_one','value_two','value_three');
echo $this->events->trigger('on_system_load',$params);
It will work fine.

I'll have a new version out in a few hours, as I think I can add more to this.
#18

[eluser]Milos Dakic[/eluser]
[quote author="tdktank59" date="1235526788"]Look good,

Ill check it out when I get a chance. Ill probably load it into a production environment once some more of the kinks are worked out![/quote]

I'm hoping to do that by maybe version 0.5, then I'll take the BETA tag off. For now the next release will be just bug fixes.
#19

[eluser]Milos Dakic[/eluser]
New version now available. Version 0.4 (beta)

Bug fix release this time only covering 2 bugs. Updated main thread to reflect version.

Feedback is welcome as per usual. =]
#20

[eluser]Milos Dakic[/eluser]
I need some feedback on this.

I'm planning to add a new parameter for the register function which will allow you to override the checking if the handler file exists.

This would come in useful when building other libraries around the Events library, and would like to pre-set events but do not want to force users to have to have the events in place.

Code:
$this->events->register('event','callback','module',override);

I would like to hear feedback from people who might want to use the library or who already are using it.




Theme © iAndrew 2016 - Forum software by © MyBB