groue / GRDBCombine

GRDB ❤️ Combine
MIT License
223 stars 16 forks source link

Is sink() preferred over assign()? #39

Closed simensol closed 4 years ago

simensol commented 4 years ago

In all the examples in the documentation, the sink() subscriber is used. For example:

let cancellable = publisher.sink(
    receiveCompletion: { completion in ... },
    receiveValue: { (players: [Player]) in
        print("Fresh players: \(players)")
    })

Are there any reasons we should not use assign() with GRDBCombine?

groue commented 4 years ago

Hello again @simensol,

GRDBCombine publishers are regular Combine publishers, and they can feed any Combine Subscriber. You can dump them into sink, assign, and process them in any possible way.

So one can argue that all the sink examples in the documentation are unnecessary. And even, as your question reveals, confusing.

I'll try to find a better balance in the way documentation is written. Until then, please dump those publishers wherever you want to :-)

simensol commented 4 years ago

Alright, thanks for answering (again)! And thanks for making this fabulous package!

groue commented 4 years ago

You're welcome! We're all learning about Combine :-)