-
Notifications
You must be signed in to change notification settings - Fork 72
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
Migrate Cache version #647
Conversation
@zenangst, thanks for your PR! By analyzing the history of the files in this pull request, we identified @JohnSundell to be a potential reviewer. |
@@ -32,6 +32,8 @@ class DataSourceTests: XCTestCase { | |||
let itemCell3 = component.componentDataSource!.tableView(tableView, cellForRowAt: IndexPath(row: 2, section: 0)) | |||
XCTAssertNotNil(itemCell3) | |||
|
|||
component.tableView?.reloadData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't do this, it will throw an exception that we are trying to deque the same index path twice with a different identifier.
Codecov Report
@@ Coverage Diff @@
## master #647 +/- ##
==========================================
- Coverage 87.82% 87.81% -0.01%
==========================================
Files 126 126
Lines 10312 10310 -2
==========================================
- Hits 9056 9054 -2
Misses 1256 1256
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #647 +/- ##
==========================================
- Coverage 87.82% 87.81% -0.01%
==========================================
Files 126 126
Lines 10312 10310 -2
==========================================
- Hits 9056 9054 -2
Misses 1256 1256
Continue to review full report at Codecov.
|
completion?() | ||
} | ||
try? cache.clear() | ||
completion?() | ||
} | ||
|
||
/// The StateCache file name | ||
/// | ||
/// - returns: An md5 representation of the StateCache's file name, computed from the StateCache key | ||
func fileName() -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this function? @zenangst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use it for the logging feature if you use live reloading :)
@@ -1,6 +1,6 @@ | |||
import Foundation | |||
import Cache | |||
import CryptoSwift | |||
import SwiftHash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove fileName
then we don't need this import anymore.
} | ||
|
||
/// Load JSON from cache | ||
/// | ||
/// - returns: A Swift dictionary | ||
public func load() -> [String : Any] { | ||
return SyncCache(cache).object(key)?.object as? [String : Any] ?? [:] | ||
guard let cachedDictionary = cache.object(forKey: key)?.object as? [String: Any] else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about guard .dictionary(let cachedDictionary) = cache.object(forKey: key)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vadymmarkov how do you mean exactly? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does .dictionary
come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON.dictionary
from Cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant guard case .dictionary(let cachedDictionary) = cache.object(forKey: key)
This migrates the
StateCache
to use the latest version ofCache
.