本文整理匯總了TypeScript中redux-package.ReduxPackageCombiner.select方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ReduxPackageCombiner.select方法的具體用法?TypeScript ReduxPackageCombiner.select怎麽用?TypeScript ReduxPackageCombiner.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redux-package.ReduxPackageCombiner
的用法示例。
在下文中一共展示了ReduxPackageCombiner.select方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: watchForAutoLogin
watchForAutoLogin(): Observable<ILoginActionPayload> {
const isAuto = (loginState: ILoginState): boolean => {
if (loginState)
return loginState.userId === null;
return false;
};
let lastLoginState = null;
ReduxPackageCombiner
.select(LOGIN_PACKAGE_NAME)
.subscribe((loginState: ILoginState) => {
lastLoginState = loginState;
});
let subject = new Subject();
this.firebase.auth().onAuthStateChanged((fbuser) => {
console.log('Log in dectected - autologin checker');
const user = transformUser(fbuser);
console.log(user);
if (user) {
checkUserProfile(this.firebase.database(), user);
subject.next(LoginActions.loginSuccessFactory(
user,
user._id,
isAuto(lastLoginState)
));
}
});
return subject;
}
示例2: ngOnInit
ngOnInit() {
// Check for deep link
let pathname:string[] = window.location.pathname.split('/');
if (pathname.length>=3) {
let subUrl:string = pathname[1];
let gameId:string = pathname[2];
if (subUrl === 'game-hand' || subUrl ==='game-table') {
if (LoginPackage.lastLoginState.loggedIn)
GameStartActions.loadGameRequest(gameId, '');
else {
const subscription = ReduxPackageCombiner.select(LOGIN_PACKAGE_NAME).subscribe( (loginState: ILoginState) => {
if (loginState.loggedIn) {
GameStartActions.loadGameRequest(gameId, '');
subscription.unsubscribe();
}
} );
}
}
}
}
示例3: watchForAutoLogin
watchForAutoLogin(): Observable<ILoginActionPayload> {
const isAuto = ( loginState: ILoginState ): boolean => {
if (loginState)
return loginState.userId === null;
return false;
};
let meteorUser = Meteor.user();
let lastLoginState = null;
ReduxPackageCombiner
.select(LOGIN_PACKAGE_NAME)
.subscribe((loginState: ILoginState) => {
lastLoginState = loginState;
});
if (meteorUser) {
return Observable.of(LoginActions.loginSuccessFactory(
this.userFromMeteorUser(meteorUser),
meteorUser._id,
isAuto(lastLoginState)
));
}
let subject = new Subject();
let timer = Observable.timer(500, 1000);
let subscription = timer.subscribe(() => {
let meteorUser = Meteor.user();
if (meteorUser) {
subject.next( LoginActions.loginSuccessFactory(
this.userFromMeteorUser(meteorUser),
meteorUser._id,
isAuto(lastLoginState)
));
subject.complete();
subscription.unsubscribe();
}
});
return subject;
};