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

Requirement check closure is called too many times #40

Open
zenled opened this issue Oct 4, 2021 · 1 comment
Open

Requirement check closure is called too many times #40

zenled opened this issue Oct 4, 2021 · 1 comment

Comments

@zenled
Copy link

zenled commented Oct 4, 2021

As explained here (1. Requirement check closure is called multiple times), the requirements check closure should be called only one time for each configuration.

Example:

{
   "ios":[
      {
         "required_version":"1.2.4",
         "last_version_available":"1.8.0",
         "notify_last_version_frequency":"ALWAYS",
         "requirements":{
            "region":"hr",
            "bluetooth":"5.0"
         }
      }
   ]
}
let url = URL(string: "https://pastebin.com/raw/qtUwSvgR")!

let options = PoVRequestOptions()

options.addRequirement(key: "region"){(value) -> Bool in
   return true // breakpoint A
}

options.addRequirement(key: "bluetooth"){(value) -> Bool in
   return true // breakpoint B
}

PrinceOfVersions.checkForUpdates(from: url, options: options){ response in
    switch response.result {
    case .success(let updateResultData):
        print("Update version: \(updateResultData.updateVersion)")
    case .failure:
        print("Failed")
        break
    }
}

Since there is only one configuration, I would expect the breakpoints A and B to be triggered exactly once. In my testing both A and B are triggered twice.

One more thing. The order does not seem to be consistent between runs (even multiple runs on the same build). Sometimes it is A,B,A,B and sometimes B,A,B,A. While this library does not promise a consistent order, this does seem strange and might indicate of a hidden bug.

@Filip2Stojanovski
Copy link
Collaborator

Hi zenled,
Thank you for reaching out and bringing this to our attention. Apologies for the delay in responding. Our team will review this issue promptly.
We appreciate your patience and understanding. If you have any additional details that could help, please feel free to share them here.
Best regards,
Filip

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

2 participants