-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding a getter #18
Comments
I'm not super keen on having a getter.
I'm not convinced that something like Badge.increment();
// or
Badge.set(Badge.get() + 1); is much better than // Note: This also handles the unread count being reduced.
Badge.set(getUnreadCount()); Also, if you don't want to attach an unreadCount to // On page load, use sophisticated algorithm to determine number of unread messages.
Badge.unreadCount = 7;
// Make sure the badge shows the right count.
Badge.set(Badge.unreadCount);
// Increment can be used to add one to the badge count.
Badge.increment = () => {
Badge.unreadCount += 1;
Badge.set(Badge.unreadCount);
}; (though note that the above could get out of sync between tabs. A better solution might do some kind of synchronization to try and avoid this). |
@raymeskhoury @marcoscaceres Any thoughts on this? |
Agree with @fallaciousreasoning‘s, um, reasoning. I also think we should leave the count management to the web application. |
I've created this issue which was spawned from a discussion on #16 (comment). The current proposal explainer says:
It seems a little incomplete for the API to have a setter but no way to get badge counts for cases where there are multiple badge setters throughout an application that don't know about each other.
Let's say I have an application that shows both a chat box and email in the same interface. It gets one new unread chat message and shows 1 as badge count and then gets 2 new unread emails.
How would the application know that there was a badge count of one before it adds a 2 to that number? Sure, I could always query or listen in on both the chat message unread number and the email unread numbers, calculate them together and then call
set()
with the total number, but that would quickly become unwieldy. Then I would probably have to store both the chat unreads and email unreads on a globally accessible object (perhapswindow
) to make it available to both chat and email logic which breaks encapsulation. Why not avoid having to do this and just allow getting the badge number easily?The text was updated successfully, but these errors were encountered: