Hey Michael, thanks for the reply. OK. so just to understand - the intention of the "priority" is "1" = first one "2" = after that one
and not the listeners with the highest (e.g. 100) priority comes first? I think this should be clarified then. I like the "first" and "last" idea, however, that makes the PHP code of the interface kind of "mixed" (allowing string and ints). Should I add some remarks / examples of the priority topic to the proposal as PR? All the best, Benni. > On 12.09.2016, at 19:18, Michael Cummings <[email protected]> wrote: > > Most of the implementations I've seen call listeners in the order they are > added when priorities are the same which is how I've also done it in my > projects. The additional feature I've found useful is allowing 'first' and > 'last' keywords for the priority when adding listeners but I'm not sure if > that should really be in the PSR or not. I can see where depending on > implementation figuring out and possibly having to reorder the listeners > could be hard to do but if everyone likes the idea it might be useful. Just > to make it clear the way I implemented it 'first' and 'last' are based on the > state at the time the listener is being added and not when the event is > called. > > For example say there are already a couple of listeners with priorities of 10 > and 20 and you use 'last' for another listener it will be given a priority of > 21 and if you added another listener with 'last' it would end up with > priority of 22 etc. If you then added one with 'first' it would be assigned > 9. I use this to add default listeners for events while allowing users to add > other listeners to override the defaults by adding them beforehand or using > 'first' and choose to handle or not. By doing this the actual priority > becomes mostly an implementation detail and I only need to worry about order > things are added and not some random magic number 😋. The main thing is the > PSR should allow as much flexibility it can while still being detailed enough > to allow make sure implementations can be interchanged which is why I thought > int was best as it should not cause any real limits for anyone. > > > > > > On Mon, Sep 12, 2016 at 8:09 AM, Benni Mack <[email protected] > <mailto:[email protected]>> wrote: > Hey Brian, > > we're from TYPO3 (CMS) are currently overhauling our event system and are > following the PSR quite closely, almost implementing it 1:1 for our CMS - > however the stagnation of the PSR doesn't bring some confidence that this PSR > is ever going to happen. However, we'd love to contribute in order to > actually make it possible to have our Event system interchangeable with other > systems. > > Some remarks on the proposal: > * Should we give a range for the "priority" (0-100 ?) otherwise it feels like > the HTML/CSS "z-index" which I just set to 4000 and will be higher than all > the others - until another framework thinks the same ;) - This is a bit > different approach than Michael's remarks, however it'd be useful have that > cleared up. > * What happens if a listener adds itself to an event but an existing listener > has the same priority? Is there an exception going to be thrown? Graceful > "upping" or "downing" the priorities? First come / first serve? We should > probably just have that cleared up and written down. > > All the best, > Benni. > > -- > You received this message because you are subscribed to a topic in the Google > Groups "PHP Framework Interoperability Group" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/php-fig/-EJOStgxAwY/unsubscribe > <https://groups.google.com/d/topic/php-fig/-EJOStgxAwY/unsubscribe>. > To unsubscribe from this group and all its topics, send an email to > [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/php-fig/c4ccbc90-7358-42a3-905b-097b0da7d0a7%40googlegroups.com > > <https://groups.google.com/d/msgid/php-fig/c4ccbc90-7358-42a3-905b-097b0da7d0a7%40googlegroups.com?utm_medium=email&utm_source=footer>. > > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "PHP Framework Interoperability Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/php-fig/CAP9GSfWYk0zabs9GOKUGpMWb3_vNvaGnDO8NxPp_0kyATqOYVw%40mail.gmail.com > > <https://groups.google.com/d/msgid/php-fig/CAP9GSfWYk0zabs9GOKUGpMWb3_vNvaGnDO8NxPp_0kyATqOYVw%40mail.gmail.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/15D51999-A2CB-4924-BC32-FB7D576F6774%40gmail.com. For more options, visit https://groups.google.com/d/optout.
