« first day (2390 days earlier)      last day (2569 days later) » 

12:32 PM
anyone there
 
 
1 hour later…
1:59 PM
Anyone use "hooks" in JS?
Interesting concept... You can do $(this).trigger("event-name"); .... then do $("#something").on("event-name", function(){ });
Really just improved my JS compatibility.
 
Custom Events can be helpful. But be careful, you easily loose track of what affects what. You might consider using a centralized event bus or store instead for more complex stuff.
 
Like what? I'm really scrub when it comes to JS.
Can you give an example or link to an example?
 
So you click on elementA, that triggers event-name on elementB which has a listener for that event which again triggers eventBand eventCon elements B and C and so on. Suddenly a single click causes a chain reaction that is really hard to follow.
 
How is that different than the way PHP functions with WordPress hooks?
 
So instead you have one central object you trigger all events on and listen to all events. That is called a central event bus. You now know that any events are only trigger on this object so it is way easier to watch this one object and see everything that happens
 
2:15 PM
So how would you make something like that?
Do you have an example somewhere I can look at?
 
This is why people use frameworks that have you covered for event management and store. :)
 
Okay, is there any particular framework which provides what you describe?
 
Sorry, don't have time to go into detail right now. Maybe tomorrow. This can really lead down a rabbit hole. I'm also not sure what you are doing. For simple stuff just trigger stuff on elements. This is really only relevant when stuff is getting more complex.
 
I'm sure my current usage is simple, but likely will grow now that I know you can do that.
 
This is why I am doing preventive warning here ;)
 
2:21 PM
Thanks for the education. ^^
 
The things is that PHP just goes through your code once. You give the server a request and he gives you a response.
With JS stuff happens caused by events. And this can also mean that multiple events can be triggered while another events is still being handled and then the exact timing can be relevant and you run into concurrency issues and then stuff gets really confusing with events spread all over the place.
Remember me tomorrow, I might have time to go more into detail then.
 
2:41 PM
Sounds good.
 
 
3 hours later…
5:48 PM
JS Events are super nice with bootstrap. For example... Maybe you have a plugin which adds a carousel to your content. Maybe you want to affix that carousel from your theme. Your theme can wait until the carousel has been loaded before applying the affixed effect to your carousel. That way affix isn't happening too early, causing overlapping content. Definitely going to start using these more in my JS.
 
 
1 hour later…
6:48 PM
:( it is already 2017. I totally understand why legacy software like wordpress is stuck with events, but what is the reason new frameworks are stuck with it instead of implementing proper observer pattern?
why is there a need for a mediator/bus instead of direct registration?
 

« first day (2390 days earlier)      last day (2569 days later) »