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

Question: why case .isLoading is not called even we got .isLoading on didSet? #76

Open
mitolog opened this issue Jan 6, 2022 · 1 comment

Comments

@mitolog
Copy link

mitolog commented Jan 6, 2022

Hi, thanks for sharing and committing such a great project.

While using your architecture, I found that the the scope below is not always called:

case .isLoading:
return AnyView(loadingView)

even though you did setIsLoading at below:

countryDetails.wrappedValue.setIsLoading(cancelBag: cancelBag)

Is this behavior intended?

What I'm expecting is that the loading view will be shown if you enter the view every time. But, it's not.


I've also checked actual value with

        @Published var details: Loadable<Country.Details> {
            willSet{
                print("willSet (\(details) -> \(newValue))")
            }
            didSet {
                print("didSet (\(oldValue) -> \(details))")
            }
        }

then I got

willSet (notRequested -> isLoading(last: nil, cancelBag: CountriesSwiftUI.CancelBag))
didSet (notRequested -> isLoading(last: nil, cancelBag: CountriesSwiftUI.CancelBag))
willSet (isLoading(last: nil, cancelBag: CountriesSwiftUI.CancelBag) -> loaded(CountriesSwiftUI.Country.Details(...)
didSet (isLoading(last: nil, cancelBag: CountriesSwiftUI.CancelBag) -> loaded(CountriesSwiftUI.Country.Details(...)

so I expected CountryDetails.swift#L29 to be run, but it's not.

It may be very basic behavior or just an overlook of me but I appreciate anyone's help.

@mitolog
Copy link
Author

mitolog commented Jan 6, 2022

As I looked definition of wrappedValue , I found notation below:

    /// When a mutable binding value changes, the new value is immediately
    /// available. However, updates to a view displaying the value happens
    /// asynchronously, so the view may not show the change immediately.
    public var wrappedValue: Value { get nonmutating set }

Is this the reason why?

p.s. If I set ensureTimeSpan before sinkToLoadable , then set time interval to 1.5 , it works as expected.

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