CustomObservable vs Observable.create()?

前端 未结 2 1401
青春惊慌失措
青春惊慌失措 2020-12-10 21:54

I\'m working on wrapping listeners into Observables. Normally we use Observable.create() to wrap that but there are libraries prefer to use custom Observables a

2条回答
  •  猫巷女王i
    2020-12-10 22:42

    Wherever possible I would use library provided creation methods like: generate, fromCallable or create. There is no overhead in them. They take care of various housekeeping issues, which you can easily forget when writing your custom observable.

    Unfortunately there are cases when you cannot use them, eg. when you need special scheduling. Before writing custom observable I would recommend looking into source code of generate or create library methods. Make sure you understand every bit of it, so you can do similar things in your observable.

提交回复
热议问题