Closed andyli closed 9 years ago
It's possible to unbind a stream, but it's not currently possible for a promise.
Keeping a promise bound is pretty useful, as it helps to catch situations where a promise resolves more than once (which can cause a lot of undesirable behavior, or expose a flaw in how you were trying to use the promise). This can only work if the promise maintains a connection to its upstream resolver.
However, for practical purposes I do agree that it's useful to clear the memory after some point. I think I'll relax some of the constraints on Stream.detachStream so it can work with promises.
In the future, you can use :
some_async.unlink(some_other_async);
This will unlink the two asyncs. Note that this operation (like the other link method) is asynchronous.
also note, the use of unlink is not really recommended.
The implementation of
Stream#first()
looks like a memory leak to me, in the sense that the returnedPromise
can never be freed since it subscribes to the stream update forever.In general, is there a way to unsubscribe?