Skip to content

koher/future-keep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FutureKeep

FutureKeep makes it possible to keep subscriptions of Futures or other Publishers in Combine until they are completed. It is useful to replace completion handlers with Futures when cancellations are not required.

// Keeps a reference to the subscription
// until it is complete.
future.get { value in
    // Uses `value` here
}

get can be used instead of sink. When we use sink, subscriptions are cancelled unless references to cancellables are kept.

// Subscriptions are cancelled
// just after the `sink` is called.
_ = future.sink { value in
    // Uses `value` here
}

When the Failure type of a Publisher is Never, closures receive an Output as its argument. Otherwise, closures receive a Result<Output, Failure>.

Notice: Using get of uncompletable Publishers causes memory leaks. Use get for only completable Publishers.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages