TwanoO67 / ngx-admin-lte

Admin LTE for Angular 2/4/6/8 as a NPM package
MIT License
108 stars 47 forks source link

Question on notification service #69

Closed MihaiHoriaPopescu closed 6 years ago

MihaiHoriaPopescu commented 6 years ago

Hello, i have some problems on updating the notifications, modify one f them, delete one of them. From the source code of notification.service i saw there is a property "public updates: Subject = new Subject();" that should be used, but i dont understand how to use it. Some sugestions?

TwanoO67 commented 6 years ago

Hello,

On that property you should emit the full array of notification you want to show.

For that you can use the notification service as seen here: https://github.com/TwanoO67/bootstraping-ngx-admin-lte/blob/master/src/app/app.component.ts

MihaiHoriaPopescu commented 6 years ago

@TwanoO67 Sorry but i did not understand how to do it.

Can you make an example of how i can delete one element of the array of notifications?

TwanoO67 commented 6 years ago

Through the https://github.com/TwanoO67/ngx-admin-lte/blob/develop/src/services/notifications.service.ts

You can access the full notification list, remove the one you don't want anymore, and submit the rest

MihaiHoriaPopescu commented 6 years ago

But the notificationList is private.

TwanoO67 commented 6 years ago

Yes but you can access the "notifications" subject to receive the last version of it

MihaiHoriaPopescu commented 6 years ago

Sorry but i dont really know how to use the rxjs lib (Subject, ReplaySubject). Can you make an example of how to modify/delete elements using the "notifications" property? Thanks.

TwanoO67 commented 6 years ago

To modify something you have the stream of updates.

myNotifService.updates.next(function(notification: Notification): INotificationsOperation { return (notifications: Notification[]) => { //here you can access the full tab of notifications // search and modify or delete the one you want // then return the full tab return notifications; }; });

TwanoO67 commented 6 years ago

If you want more big picture advise on rxjs I recommend this tutorial here:

https://gist.github.com/staltz/868e7e9bc2a7b8c1f754

MihaiHoriaPopescu commented 6 years ago

Ok, thanks!