Skip to content

💡 Add a get method #43

Open
Open
@pjechris

Description

@pjechris

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions