@BindableObject async call to didChange.send() does not invalidate its view (and never updates)

后端 未结 1 1959
梦毁少年i
梦毁少年i 2021-01-28 06:50

I have found what I think is a bug in @ObjectBinding. For cases when a @BindableObject get its didChange.send() called asynchronously, sometimes views that depend on that change

相关标签:
1条回答
  • 2021-01-28 07:18

    You need to replace your didChange with let objectWillChange = ObservableObjectPublisher() as ObservableObject implicitly already implements a PassthroughtSubject.

    Also, Apple docs recommends now to use @Published instead of the didSet: @Published var value: Int = 1

    In your update function, replace self.update() with self.objectWillChange.send()

    I found this link explaining how to trigger a view invalidation.

    0 讨论(0)
提交回复
热议问题