kefirjs/kefir

Add .end() to Kefir.pool()

Open

#137 创建于 2015年9月2日

在 GitHub 查看
 (15 评论) (0 反应) (0 负责人)JavaScript (1,846 star) (107 fork)batch import
enhancementhelp wanted

描述

I've got a puzzle with a framework I'm putting together, where I would like to be able to properly dispose of promises when they are no longer needed (and unsubscribe from the relevant streams).

I believe a subscription is made in order to back the Promise, but when program logic establishes that the promise is no longer needed I can't find anything which can be done to tidy up and unsubscribe from the stream, as the onX handler is hidden within Kefir, meaning the stream would remain subscribed indefinitely with all its underlying resources committed.

If there is some way to e.g. trigger Promise rejection/fulfilment which could cause unsubscription, or to get hold of the subscribed value- and end-handler(s) to manually unsubscribe, that would be very useful to know.

Equally, perhaps there's a Kefiric way to tackle this with a minimum of weirdness (perhaps creating some kind of derived stream, creating the Promise from the derived stream, then manipulating the derived stream causing the unsubscription). I haven't been able to pin down the right transformation of a stream which would permit this, yet. Pool would be promising, but it never ends, so I can't externally induce the toPromise to complete.

If there is no obvious way, perhaps this could be a feature request for there to be some channel for unsubscription and termination of Promises.

贡献者指南