Skip to content

Commit

Permalink
Remove the parameters of onconfigchange
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Jan 30, 2020
1 parent 23cb94b commit cd3b5cc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ConfigCat.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "ConfigCat"
spec.version = "3.0.0"
spec.version = "3.1.0"
spec.summary = "ConfigCat Swift SDK"
spec.swift_version = "4.2"

Expand Down
2 changes: 1 addition & 1 deletion Sources/AutoPollingPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class AutoPollingPolicy : RefreshPolicy {
let cached = self.cache.get()
if response.isFetched() && response.body != cached {
self.cache.set(value: response.body)
self.onConfigChanged?(response.body, AutoPollingPolicy.parser)
self.onConfigChanged?()
}

if !self.initialized.getAndSet(new: true) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ConfigCatClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import os.log

extension ConfigCatClient {
public typealias ConfigChangedHandler = (String, ConfigParser) -> ()
public typealias ConfigChangedHandler = () -> ()
}

/// A client for handling configurations provided by ConfigCat.
Expand Down
9 changes: 4 additions & 5 deletions Tests/AutoPollingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,20 @@ class AutoPollingTests: XCTestCase {
mockSession.enqueueResponse(response: Response(body: "test", statusCode: 200))
mockSession.enqueueResponse(response: Response(body: "test2", statusCode: 200))

var newConfig = ""
var called = false

let mode = PollingModes.autoPoll(autoPollIntervalInSeconds: 2, onConfigChanged: { (config, parser) in
newConfig = config
let mode = PollingModes.autoPoll(autoPollIntervalInSeconds: 2, onConfigChanged: { () in
called = true
})
let fetcher = ConfigFetcher(session: mockSession, apiKey: "", mode: mode)
let policy = mode.accept(visitor: RefreshPolicyFactory(fetcher: fetcher, cache: InMemoryConfigCache()))

sleep(1)

XCTAssertEqual("test", newConfig)
XCTAssertTrue(called)

sleep(3)

XCTAssertEqual("test2", newConfig)
XCTAssertEqual("test2", try policy.getConfiguration().get())
}
}

0 comments on commit cd3b5cc

Please sign in to comment.