Skip to content

Instantly share code, notes, and snippets.

@adamdickinson
Created October 10, 2019 06:20
Show Gist options
  • Save adamdickinson/18b7ca6c6e0bb63f81476d9ddcb0bed0 to your computer and use it in GitHub Desktop.
Save adamdickinson/18b7ca6c6e0bb63f81476d9ddcb0bed0 to your computer and use it in GitHub Desktop.
const notifications [
{ id: 1 }
]; // store.get("notifications")
const watchers = [
{ notificationId: 1, userId: 1 }
{ notificationId: 1, userId: 2 }
{ notificationId: 2, userId: 2 }
]; // store.get("watchers")
notifications() {
const notifications = store.get("notifications");
notifications
.map(notification => {
...notification,
watching: watchers.some(({ notificationId, userId }) => notification.id === notificationId && userId === 1);
});
return notifications;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment