jamesdempsey
jamesdempsey

I want use Combine reading a plist from disk.

I believe I can read the file and get its Data, then use a PassthroughSubject as the publisher of the Data, and do the decode operator, etc.

Is there a way to read a file and have that be the Publisher w/o the PassthroughSubject?

|
Embed
Progress spinner
heckj
heckj

@jamesdempsey I haven't tried aiming it at a file URL, but dataTaskPublisher looks like it's specifically aimed at that task, especially with the decode() operator also supporting plist decoding.

|
Embed
Progress spinner
jamesdempsey
jamesdempsey

@heckj Thank you! Where does dataTaskPublisher live?

|
Embed
Progress spinner
heckj
heckj

@jamesdempsey URLSession (example ref using it: heckj.github.io/swiftui-n...). Its one of the Foundation pieces that had a little Combine work done on it.

|
Embed
Progress spinner
In reply to
jamesdempsey
jamesdempsey

@heckj Someone also suggested using a Future publisher with the file access calls in the promise closure.

|
Embed
Progress spinner
heckj
heckj

@jamesdempsey Publishers.Future definitely seems to be the combine utility infielder.

|
Embed
Progress spinner
jamesdempsey
jamesdempsey

@heckj Which I think makes sense, having a general publisher adaptor for async APIs, instead of necessarily adding specific publisher API to all async things.

|
Embed
Progress spinner