Comments (7)
I implemented the feature, it works fine, but now I have to use the null coalescing operator on
_open = ReactiveCommand.Create( () => Path.Combine(CurrentPath ?? _provider.InitialPath, SelectedFile.Name), canOpenCurrentPath, mainThread);
This is due to retracing _back. Eventually you can return to the null value. I don't know how to set a value to CurrentPath that initializes it from the constructor and never lets it be null. If there is a way please let me know how. If not this is way more work than it is solving as now I am chasing that null it can hit at run time.
Totally appreciate any idea on how best to solve this, right now it is a really poor way to handle CurrentPath and error prone at run time. The resulting code is more dangerous than just using a private set since and future changes will not necessarily understand that the value can return to null. I was surprised when I got hit with it.
I will Pull request soon so you can take a look.
Thanks,
Greg
from camelotia.
About the null. I was referring to the fact that on startup:
public string CurrentPath => _currentPath?.Value;
is uninitialized and in fact null.
You already are managing around this null. If you remove the Elvis operator from this:
public string CurrentPath => _currentPath?.Value;
an exception will be thrown.
I am not a fan of the FodyWeavers for this because I cannot easily determine or breakpoint when a field is set. So reading code to find the actual set is more time consuming and if I wanted to break on all set calls I have to find all the places it might actually be set. So if a field changed unexpectedly somewhere in the code trapping that is made more difficult. I think using set with RaiseAndSetIfChanged is one additional line per field that is worth it. You can always make it a private set and get the same data security as Fody. Fody just changes a private set with a reflection set and does not prohibit multiple calls in the viewmodel from stepping on each other. The fody way removes the one path to set and created multiple paths to set. Just a personal preference.... Everyone has there own :) When "Magic" happens its always harder to debug when something goes wrong.
from camelotia.
Good day @gamidon and thank you for your contribution.
I agree the issue you describe exists and should be resolved. I think introducing a new IProvider.InitialPath
property could be a better option, with such property we could let the providers decide where to start displaying files on their own.
Then, for most cloud file storages, the IProvider.InitialPath
property should be /
and for local file storage it'll be something like drives
or my-computer
or something like that (using null
s as valid values generally doesn't seem to be a good idea, and here is explained why).
I would really appreciate if you could provide an implementation for this. Might be worth opening a work-in-progress PR to avoid merge conflicts etc.
from camelotia.
I see your point, thanks! Worth mentioning that Fody doesn't actually modify those get-only properties. The ObservableAsPropertyHelper<T>
is a ReactiveUI feature, Fody uses code generation only for properties marked with [Reactive]
attribute. I prefer OAPHs because of their immutability, OAPH properties always reflect latest values that have been sent through an IObservable stream. This allows us to describe relations among properties and commands declaratively and "express the idea around a feature in one readable place", the app won't compile if the developer accidentally tries to mutate a property in a non-reactive manner. Elvis operator is used for CurrentPath
property because that property is used inside a WhenAny
call before the CurrentPath
property is initialized, I can admit it's kind of a hack to avoid dealing with mutable state where it is not entirely neccessary. :) So I agree that sometimes using nulls is a necessary evil, but if there is a chance to avoid that, it's worth trying.
from camelotia.
@gamidon the solution you are looking for is passing the InitialPath
value to ObservableAsPropertyHelper that controls the CurrentPath
property. You need to pass the InitialPath
value as a parameter to a .ToProperty
call, the parameter name is initialValue
. An example:
_currentPath = pipeline
.ToProperty(this, x => x.CurrentPath, initialValue: provider.InitialPath); // *
Docs. Another option is doing:
public string CurrentPath => _currentPath?.Value ?? "defaultValue";
from camelotia.
Closing this as resolved by #6
Thanks @gamidon ❤️ 👍
from camelotia.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from camelotia.
Related Issues (12)
- Add Yandex Disk File Provider HOT 1
- update links HOT 1
- [Bug]: UWP app won't build due to certain views not being recognised
- Why don't you put the release packages on GitHub? HOT 3
- GitHub provider doesn't support two-factor authentication HOT 1
- Dependency Dashboard
- LocalFileSystemProvider.GetSizeOnAllDisks throws "System.IO.IOException: The device is not ready" HOT 3
- [Bug]: Can not complie successfully
- logo contribution HOT 7
- Use Akavache to store auth tokens locally HOT 1
- Google and yandex autentification
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camelotia.