-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cachePolicy to ApolloClient#fetch
- Loading branch information
1 parent
cbc245b
commit 76caa60
Showing
4 changed files
with
400 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Foundation | ||
|
||
class AsynchronousOperation: Operation { | ||
class func keyPathsForValuesAffectingIsExecuting() -> Set<String> { | ||
return ["state"] | ||
} | ||
|
||
class func keyPathsForValuesAffectingIsFinished() -> Set<String> { | ||
return ["state"] | ||
} | ||
|
||
enum State { | ||
case initialized | ||
case ready | ||
case executing | ||
case finished | ||
} | ||
|
||
var state: State = .initialized { | ||
willSet { | ||
willChangeValue(forKey: "state") | ||
} | ||
didSet { | ||
print(state) | ||
didChangeValue(forKey: "state") | ||
} | ||
} | ||
|
||
override var isAsynchronous: Bool { | ||
return true | ||
} | ||
|
||
override var isReady: Bool { | ||
let ready = super.isReady | ||
if ready { | ||
state = .ready | ||
} | ||
return ready | ||
} | ||
|
||
override var isExecuting: Bool { | ||
return state == .executing | ||
} | ||
|
||
override var isFinished: Bool { | ||
return state == .finished | ||
} | ||
} |
Oops, something went wrong.