Summary
Today we have find methods which returns a successful observer only if the value is already stored.
Idea would be to add a get counterpart which would always suceeds. This would allow to declare an observer even if the value is not yet present.
To be consistent find(named:) would be renamed get(named:) as aliases never fail
Basic Example
identityMap.find(Foo.self, id: 1) // returns nil because value is not stored yet
identityMap.get(Foo.self, id: 1) // returns an Observer even if value is not stored. Might never receive any value if Foo(id:1) is never stored
identityMap.store(Foo(id: 1, title: "hello world")) // observer is notified
Unresolved questions
Implementing such feature would require refactoring on how observers are handled currently: for now observer is tightly tied with the presence of the value in IdentityMap.
We would need a way of declaring such an observer even when value is not stored yet.
Summary
Today we have
findmethods which returns a successful observer only if the value is already stored.Idea would be to add a
getcounterpart which would always suceeds. This would allow to declare an observer even if the value is not yet present.Basic Example
Unresolved questions
Implementing such feature would require refactoring on how observers are handled currently: for now observer is tightly tied with the presence of the value in IdentityMap.
We would need a way of declaring such an observer even when value is not stored yet.