File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ public protocol Atom {
1212 /// A loader type that represents an actual implementation of the corresponding atom.
1313 associatedtype Loader : AtomLoader where Loader. Coordinator == Coordinator
1414
15+ /// A type to coordinate with the atom.
1516 associatedtype Coordinator = Void
1617
1718 /// A type of the context structure that to read, watch, and otherwise interacting
@@ -33,6 +34,13 @@ public protocol Atom {
3334 /// If this atom conforms to `Hashable`, it will adopt itself as the `key` by default.
3435 var key : Key { get }
3536
37+ /// Creates the custom coordinator instance that you use to preserve arbitrary state of
38+ /// the atom.
39+ ///
40+ /// It's called when the atom is initialized, and the same instance is preserved until
41+ /// the atom is no longer used and is deinitialized.
42+ ///
43+ /// - Returns: The atom's associated coordinator instance.
3644 func makeCoordinator( ) -> Coordinator
3745
3846 // --- Internal ---
@@ -47,9 +55,13 @@ public extension Atom {
4755 false
4856 }
4957
50- func makeCoordinator( ) -> Coordinator where Coordinator == Void { ( ) }
58+ func makeCoordinator( ) -> Coordinator where Coordinator == Void {
59+ ( )
60+ }
5161}
5262
5363public extension Atom where Self == Key {
54- var key : Self { self }
64+ var key : Self {
65+ self
66+ }
5567}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ public protocol AtomLoader {
44 /// A type of value to provide.
55 associatedtype Value
66
7+ /// A type to coordinate with the atom.
78 associatedtype Coordinator
89
910 /// The context structure that to interact with an atom store.
You can’t perform that action at this time.
0 commit comments