如何将Signal转换为SignalProducer

时间:2015-11-26 12:00:17

标签: ios reactive-cocoa reactive-cocoa-3

不幸的是,某些RAC片段不提供SignalProducer,但Signal s(Action}的values字段为SignalSignalProducer。但是根据我的逻辑,我需要Signal

如何将SignalProducer转换为toSignalProducer(toRACSignal(x))

public void ConfigureAuth(IAppBuilder app) { app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions { }); app.UseWsFederationAuthentication( new WsFederationAuthenticationOptions { Wtrealm = ConfigurationManager.AppSettings["ida:Audience"], AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType, TokenValidationParameters = new TokenValidationParameters { SaveSigninToken = true, ValidAudience = ConfigurationManager.AppSettings["ida:Audience"], }, Configuration = getWsFederationConfiguration() } ); } private static WsFederationConfiguration getWsFederationConfiguration() { WsFederationConfiguration configuration = new WsFederationConfiguration { Issuer = ConfigurationManager.AppSettings["wsFederation:trustedIssuer"], TokenEndpoint = ConfigurationManager.AppSettings["wsFederation:issuer"], }; configuration.SigningKeys.Add(new X509SecurityKey(new X509Certificate2(Convert.FromBase64String(ConfigurationManager.AppSettings["wsFederation:trustedIssuerSigningKey"])))); return configuration; } 似乎不是一个好的解决方案

1 个答案:

答案 0 :(得分:0)

目前我停止了此扩展程序:

extension Signal {

    func toSignalProducer() -> SignalProducer<T, E> {
        return SignalProducer { (sink, compositeDisposable) in
            compositeDisposable.addDisposable(self.observe(sink))
        }
    }

}