Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, ask a question about Disposable, thanks #836

Open
ijunfly opened this issue Jul 25, 2021 · 1 comment
Open

Hello, ask a question about Disposable, thanks #836

ijunfly opened this issue Jul 25, 2021 · 1 comment

Comments

@ijunfly
Copy link

ijunfly commented Jul 25, 2021

Hello everyone, after I created a SignalProducer, Disposable was weakly referenced, but after the SignalProducer was executed, Disposable was also printed, but why is the Disposable status incorrect?

class ViewController: UIViewController {
    weak var testDisposable: Disposable?
}

        self.testDisposable = SignalProducer(value: 3).delay(1, on: QueueScheduler.main).take(duringLifetimeOf: self).on(starting: {
            print("SignalProducer(value: 3) starting")
        }, started: {
            print("SignalProducer(value: 3) started")
        }, event: { (event) in
            print("SignalProducer(value: 3) event")
        }, failed: { (failed) in
            print("SignalProducer(value: 3) failed")
        }, completed: {
            print("SignalProducer(value: 3) completed")
        }, interrupted: {
            print("SignalProducer(value: 3) interrupted")
        }, terminated: {
            print("SignalProducer(value: 3) terminated")
        }, disposed: {
            print("SignalProducer(value: 3) disposed")
        }, value: { (x) in
            print("SignalProducer(value: 3) value: \(x)")
        }).start()
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
            let a = self.testDisposable?.isDisposed == true
            print("self.testDisposable.isDisposed : \(a)")
        }

log

SignalProducer(value: 3) starting
SignalProducer(value: 3) started
SignalProducer(value: 3) event
SignalProducer(value: 3) value: 3
SignalProducer(value: 3) event
SignalProducer(value: 3) completed
SignalProducer(value: 3) terminated
SignalProducer(value: 3) disposed
self.testDisposable.isDisposed : false

谢谢各位大佬, Thank you !!!!

@ijunfly
Copy link
Author

ijunfly commented Jul 26, 2021

This can be used in ReactiveObjC, but it is different in ReactiveSwift.
Thanks again, Thanks again, Thanks again,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant