小编dan*_*nym的帖子

ngrx链接动作/效果 - 例如登录然后导航

我是ngrx和Redux风格架构的新手,我在理解如何链接动作/效果方面遇到了问题.一个例子是实现基本功能,例如在用户登录后采取行动.我的核心斗争是在用户登录后要采取的行动将根据应用程序的当前状态而变化 - 用户可能在任何地方在提交登录提示/页面时在应用程序中.

我见过的任何一些例子,一旦用户登录就会发生硬编码效果.在我的场景中,这不符合上述说法,我并不总是希望同样的动作发生.

以下是包含登录组件的主页的一些示例代码.在这种情况下,我希望用户在登录后重定向到"/ buy".

@Component(..)
export class HomePageComponent {
    constructor(private store: Store<any>) {
    }

    public onLoginSubmitted(username, password) {
        this.store.dispatch(new loginActions.Login({username, password}));
        // once this has happened successfully navigate to /buy    
    }

}
Run Code Online (Sandbox Code Playgroud)

示例效果

@Injectable()
export class LoginEffects {

    ......     

    @Effect()
    login$ = this.actions$
        .ofType(loginActions.ActionTypes.LOGIN)
        .switchMap((data) => {
            return this.loginService.login(data.payload)
                .map(() => new loginActions.LoginSuccess({loggedIn: true, isLoggingIn: false}))
                .catch((error) => {
                    return of(new loginActions.LoginError({loggedIn: false, isLoggingIn: false}));
                });
        });
    ......
}
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题,我有几点想法 - 但他们都不是正确的.这些包括

  • 使用登录有效负载传递数据以确定下一步要采取的操作
  • 写一些在LoginSuccess上采取行动但在某个更高级别过滤的效果
  • 通过监听商店中的事件来编写特定于组件的效果(这是可能/不好的做法吗?)
  • 从商店读取有关当前登录状态的数据并在组件中对此进行操作.然而,这种逻辑会立即运行,这可能不会产生预期的效果

任何人都可以指出我应该如何解决这个问题的正确途径/现有例子吗?

ngrx ngrx-effects angular

11
推荐指数
1
解决办法
6130
查看次数

列表命令在xcode中挂起

我正在使用Jenkins Xcode插件(https://wiki.jenkins-ci.org/display/JENKINS/Xcode+Plugin)来构建一个iOS应用程序,但是当我从另一个项目继承的项目上运行以下命令时它会挂起开发商:

$ /usr/bin/xcodebuild -list    
Run Code Online (Sandbox Code Playgroud)

当我从终端手动运行此命令时,它也会挂起.有谁知道原因可能是什么?显示的警告也显示在我拥有的另一个项目上,但在这种情况下它不会挂起.

在OS X 10.10上运行Xcode 6.1

$ /usr/bin/xcodebuild -list
2014-11-12 04:47:21.234 xcodebuild[42642:1431240] [MT] DVTAssertions: Warning in /SourceCache/IDEFrameworks/IDEFrameworks-6604/IDEFoundation/SourceControl/Model/IDESourceControlManager.m:423
Details:  Error Domain=com.apple.dt.IDESourceControlErrorDomain Code=-1 "Missing extension: public.vcs.subversion" UserInfo=0x7f9792309200 {NSLocalizedDescription=Missing extension: public.vcs.subversion}
Object:   <IDESourceControlManager: 0x7f9792302860>
Method:   -loadRepositories
Thread:   <NSThread: 0x7f9790d2dbe0>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Information about project "DOHSmokefree":
Targets:
    DOHSmokefree
    DOHSmokefreeTests

Build Configurations:
    Debug
    Release

If no build configuration is …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios jenkins-plugins

7
推荐指数
1
解决办法
4860
查看次数

使用sass/less的CSS'lookbehind'

我目前正在使用sass来帮助构建我的CSS.下面给出了一个小问题.

.container {
    .list {
        .selected {
            background-image : url('highlighted.png');
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我也在使用modernizr(http://modernizr.com/docs/)并希望在可能的情况下使用CSS3.在这个例子中,我想测试可用性border-radius,border-radius而不是使用背景图像.因此,我需要检查元素borderradius上是否存在类html.是否有可能使用某种背后的外观来实现这一目标?或者我必须再次使用.borderradius该类重复代码,最终结果如下:

.container {
    .list {
        .selected {
            background-image : url('highlighted.png');
        }
    }
}

.borderradius .container {
    .list {
        .selected {
            background : yellow;
            border-radius : 10px;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

对我来说,这看起来很麻烦,很难在大型项目中维护.有没有人有更优雅的方法来实现这一目标?

css sass css3 less modernizr

2
推荐指数
1
解决办法
675
查看次数

标签 统计

angular ×1

css ×1

css3 ×1

ios ×1

iphone ×1

jenkins-plugins ×1

less ×1

modernizr ×1

ngrx ×1

ngrx-effects ×1

sass ×1

xcode ×1