Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Combine Start With Subject

Combine Start With Subject

Subject からはじめる Combine

Mobile Act ONLINE #2 を開催しました #MobileAct - usami-kの日記
https://usami-k.hatenablog.com/entry/2020/10/10/135009

Mobile Act ONLINE #2
https://mobileact.connpass.com/event/189045/

登壇時の指摘を受けて一部修正済(P.13)

USAMI Kosuke

October 09, 2020
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. 9DPEF1MBZHSPVOEͰ͙͢ಈ͔ͤΔྫ let subject = PassthroughSubject<String, Never>() subject .sink { value

    in print("Received value:", value) } subject.send("͋") subject.send("͍") subject.send("͏") 8/17
  2. /PUJpDBUJPO$FOUFSͷྫ w $PNCJOF鱳ղઆ鱬鲍鱔࢖鲔鲑鲐 let myNotification = Notification.Name("MyNotification") let publisher =

    NotificationCenter.default.publisher(for: myNotification) publisher .sink { value in print("Received value:", value) } 10/17
  3. 4VCKFDUͷܕফڈ w Subject鲗AnyPublisherܕ鱭鱜鱫ݟ鱠鲐 let subject = PassthroughSubject<String, Never>() let publisher

    = subject.eraseToAnyPublisher() w 鲜鳑鳫鳀ड৴ଆ鱰鱴publisher鱳鲀鱋鲗࢖鲔鱠鲐 w ࣮ࡍ鱳鲚鳏鳢ઃܭ鱬鱴ɺ্ड़鱳ํ๏鲗ར༻鱞鲐鱳鱑޷鲃鱜鱉 16/17