Skip to content
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

AsReadonlyView extension method #76

Open
JohanLarsson opened this issue May 27, 2019 · 2 comments
Open

AsReadonlyView extension method #76

JohanLarsson opened this issue May 27, 2019 · 2 comments

Comments

@JohanLarsson
Copy link
Member

var view = foo.ObserveValue(x => x.Items).AsReadOnlyView();

JohanLarsson added a commit that referenced this issue Sep 7, 2019
@JohanLarsson
Copy link
Member Author

JohanLarsson commented Sep 7, 2019

Workaround 1:

var view = foo.ObserveValue(x => x.Items)
              .Select(x => x.GetValueOrDefault())
              .AsReadOnlyView()

Workaround 2:

var view = foo.ObserveValue(x => x.Items)
              .Select(x => (IMaybe<int[]>)x)
              .AsReadOnlyView()

We can add ObserveEnumerableValue() that returns IMaybe<IEnumerable<T>> but not sure it is worth it.

Another alternative is to generate overloads for common collection types but it will not work for immutable collections which is a common use case.

JohanLarsson added a commit that referenced this issue Sep 7, 2019
@JohanLarsson
Copy link
Member Author

Not doing anything with this, chances are shapes will solve it in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant