本文整理汇总了TypeScript中@ngxs/store.Store.selectOnce方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.selectOnce方法的具体用法?TypeScript Store.selectOnce怎么用?TypeScript Store.selectOnce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ngxs/store.Store
的用法示例。
在下文中一共展示了Store.selectOnce方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('it should set location', () => {
store.dispatch(new SetLocation({ latitude: 10, longitude: 10 }));
store.selectOnce(state => state.filter.location).subscribe(location => {
expect(location.latitude).toBe(10);
expect(location.longitude).toBe(10);
});
});
示例2: it
it('should handle logout', () => {
const credentials = new UserCredentials('my-user', 'my-pass');
const user = new AuthenticatedUser(credentials.username, 'testing-token', [
new UserAuthority('AUTH_1'),
new UserAuthority('AUTH_2'),
new UserAuthority('AUTH_3')
]);
store.dispatch(new LoginAction(credentials));
const testResponse = {
token: user.token,
authorities: user.authorities.map(val => val.name)
};
const request = backend.expectOne(`/api/login`);
request.flush(testResponse);
backend.verify();
store.dispatch(new LogoutAction());
store.selectOnce(SessionState).subscribe(state => {
expect(state).toBeTruthy();
expect(state).toBe(defaultSessionState);
});
expect(location.path()).toBe('');
});
示例3: it
it('it closes side navigation panel', () => {
store.dispatch(new CloseSidenav());
store.selectOnce(state => state.layout.showSidenav).subscribe(showSidenav => {
expect(showSidenav).toBe(false);
});
});