Skip to content

Starting Client doesn't bring client online #185

@ugiacoman

Description

@ugiacoman

Describe the bug
After starting the client, I expect the client to be online. If I check the status of the client inside of its completion block, it says we are online. However, if I immediately check my variation, I get the fallback value.

To reproduce
This behavior is reproducible when there is no cache, ie the first run.

func testLD() {
    let config = LDConfig(mobileKey: "test")
    let user = LDUser(key: "test")
    LDClient.shared.start(config: config, user: user) {
        if LDClient.shared.isOnline {
            let variation = LDClient.shared.variation(forKey: "key", fallback: "fallback")
            print("variation: \(variation)") // prints "variation: fallback"
        }
    }
    
    // If I run this method after calling start and then try
    // accessing my variation inside of the callback, I get the actual value
    LDClient.shared.setOnline(true) {
        let variation = LDClient.shared.variation(forKey: "key", fallback: "fallback")
        print("variation: \(variation)") // prints "variation: on"
    }
}

Expected behavior
Accessing variation after starting the client should work if we are online.

Logs
N/A

SDK version
4.1.0

Language version, developer tools
N/A

OS/platform
iOS

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions