Combine

Combineのdebounceを試す

開発環境 > xcodebuild -version Xcode 13.3 Build version 13E113 モチベーション debounceを使ったことがないので使ってみたい debounce Publishes elements only after a specified time interval elapses between events. https://developer.apple.com/d…

SwiftUI x Combine 練習1

本記事は下記を参考にしています。 blog.studysapuri.jp 前々からやりたかったSwiftUIとCombineを組み合わせた実装をやってみる! 開発環境 > xcodebuild -version Xcode 13.1 Build version 13A1030d 作ったもの 2.5秒ごとに [1, 2, 3, 4, 5] をシャッフル…

「Combineをはじめよう」を読んだ

nextpublishing.jp 第2章 SubscribeとSubscription import Combine let subject = PassthroughSubject<String, Never>() final class Receiver { let subscription: AnyCancellable init () { subscription = subject .sink { value in print("received:", value) } } } let</string,>…

sink(receiveValue:)の戻り値を破棄せずに保持しておく必要がある理由を探す

本記事は下記を参考にしています。 nextpublishing.jp 結論 そういう仕様。 This method creates the subscriber and immediately requests an unlimited number of values, prior to returning the subscriber. The return value should be held, otherwise…