【发布时间】:2021-07-21 10:44:12
【问题描述】:
ngrx 中的createEffect 与@Effect 注释有什么区别?
@Injectable()
export class ContactsEffects {
constructor(
private actions$: Actions,
private contactsService: ContactsService,
private contactsSocket: ContactsSocketService
) {}
destroy$ = createEffect( () => this.actions$.pipe(
ofType(remove),
pluck('id'),
switchMap( id => this.contactsService.destroy(id).pipe(
pluck('id'),
map(id => removeSuccess({id}))
))
));
@Effect()
liveCreate$ = this.contactsSocket.liveCreated$.pipe(
map(contact => createSuccess({contact}))
);
}
【问题讨论】:
标签: javascript angular typescript decorator ngrx