如何根据来自第一流的事件来初始化第二流?

时间:2019-04-03 07:31:59

标签: dart flutter rxdart

在我的BLOC中,我需要听FirebaseAuth.instance.onAuthStateChanged,并且取决于用户uid将初始化第二个流Firestore.instance.collection('accounts/${uid}/private').snapshots()并将结果组合为一个模型:

    class MyPageModel {
      bool userSignedIn;
      List<String> privateData;
    }

此模型需要与BehaviorSubject一起流式传输。使用rxdart完成此任务的最佳方法是什么?

1 个答案:

答案 0 :(得分:1)

检查下面的代码,看看如何组合两个条件流:

library(ggplot2)
library(stringr)

dataset$preguntasCortas = str_wrap(dataset$preguntas, width = 8)

ggplot (data = dataset, 
    aes(x = preguntasCortas, y = valores, fill = valores)
) +
   geom_bar(width = .4, stat = "identity", na.rm = TRUE)+
   scale_fill_gradient(low = "gray", high = "red", limits = c(1, 6)) + 
   coord_polar() + 
   scale_y_discrete(limits = c(0,7)) + 
   theme(
        axis.text.y = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 0,hjust = 0),
        legend.title = element_blank(), 
        legend.text = element_text(size = 10),  
        axis.title =  element_blank(),
        axis.ticks = element_blank(),
        panel.background = element_rect(fill = "transparent", color = NA),        
        plot.margin = unit(c(-.1, -.1, -.1, -.1), "cm"),
        text = element_text(
        family = "Century Gothic", size=5, color = "#595959"
    )
)