Let's build our own custom event system implementation! 🔥
Create a class to implement the three functions I mentioned. We'll put all of our registered events into an array, and call them when we fire an event.
Live example: stackblitz.com
Here's what it looks like 👇
Create a class to implement the three functions I mentioned. We'll put all of our registered events into an array, and call them when we fire an event.
Live example: stackblitz.com
Here's what it looks like 👇
Don't actually do that in the real world, this is meant for educational purposes - the native and React's event systems work similarly.
That's it! Hope you had fun, and if you did:
1. Follow me @VincasStonys for more like this
2. RT the first tweet to share this with others 🙏
That's it! Hope you had fun, and if you did:
1. Follow me @VincasStonys for more like this
2. RT the first tweet to share this with others 🙏
Loading suggestions...