Open kuraga opened 9 years ago
Is emit
still valid?
TypeError: freezer.emit is not a function
Hey @Tjorriemorrie
emit
is now the way of trigger events. trigger
is deprecated. If you are seeing that message is either because you are using an old version of freezer, or you are not initalizating the store properly
This should work:
import Freezer from 'freezer-js';
var freezer = new Freezer({});
freezer.emit('my:event');
Thanks, I was stuck on 0.11 for some reason. This is such a great library.
I am glad you liked it :) I am preparing a little a article with freezer patterns to celebrate the 1000 stars, keep tuned!
In fact! Here it is the article draft. If you want to preview and share your thoughts I'll be so grateful: https://medium.com/@arqex/7-tips-using-react-with-freezer-f4d75e363b94
It's a good article. Maybe touch on how redux selectors are similarly handled. And also when freezer.on is added to the component, does it create a listener? Meaning do I have to unset the listener/something when the component unmounts (or only specifically when freezer's addListener was used)?
By selector you mean this? https://github.com/reactjs/reselect
It's great, I had never heard of them and I think it's possible to use them with freezer out of the box.
Good appreciation on stop listening events on components that are using freezer.on
. In the article I suggest to only have one listener at the top component of your React tree. In my case that component is never unmounted so I will never need to stop listening. It's cool, one thing less I need to care about.
We have to check if every API method is mentioned in docs.