如果没有可用的Sync实例,如何运行FS2流?

时间:2018-06-13 13:16:48

标签: scala fs2

如果我最终以Stream[Id, A]translate Pure Id ~> Pure效果Stream[Option, A]

但是,如果我最终得到了一个不同的严格效果类型的流,例如Option[Vector[A]],如何将其转换为Sync(或其他内容)?到目前为止,我发现的最好的方法是将流转换为 具有Sync实例的其他类型,运行流,但是将其转换回来并不是直接的Throwable承认所有Option为失败,而None自然只允许public class MyLifecycleHandler implements Application.ActivityLifecycleCallbacks { private static int resumed; private static int paused; private static int started; private static int stopped; private static String currentActivity; public static String getCurrentActivity() { return currentActivity; } @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { currentActivity = activity.getClass().getSimpleName(); } @Override public void onActivityDestroyed(Activity activity) { } @Override public void onActivityResumed(Activity activity) { ++resumed; } @Override public void onActivityPaused(Activity activity) { ++paused; android.util.Log.w("test", "application is in foreground: " + (resumed > paused)); // send broadcast from here to the service sendBroadcast() } @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) { } @Override public void onActivityStarted(Activity activity) { ++started; } @Override public void onActivityStopped(Activity activity) { ++stopped; android.util.Log.w("test", "application is visible: " + (started > stopped)); } public static boolean isApplicationVisible() { return started > stopped; } public static boolean isApplicationInForeground() { return resumed > paused; } } 。接近这个的更好方法是什么?

0 个答案:

没有答案