-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
store.get() default value #215
Comments
Are you using the |
I'm using defaults. So i have something like this config-defaults.js
And loading it like
So lets say the user in his physical config.json file only have the something1 test item, but i introduce the something2 test item in defaults. I would suspect that this would be true, but its not, its returning undefined.
But what i get is the following
Obviously i can achive my end goal by setting the static value down the line in my code.
But that kind of makes the whole defaults redundant :) PS. I thought also that only the "scheme" part is for validating store.set() etc. Does store.get get it's default value from there when it does not exists in the users config file etc. ? |
I just did some testing, and yes it's me that have not understood the relationship between defaults and scheme. I have to maintain 2 files, one for how the default config file is going to look and on to "validate" not only what it accepts but also whats default if its not found in the physical config file. That is fine by me, i'm just glad it worked out :) For anyone querulous in what you should do i now have this setup. config-defaults.js
And config-scheme.js
And loads it all up like
And now i get the desired result/output like the following (where the user don't have the latest changes in his physical config file.
|
Hi,
if I create a new "store" with defaults set. Why does my get not return them ?
So what i'm basically is looking for is that the users actualy config.json file is out of sync with the defaults.
So lets say
Code updated to include new "
something2
"test.item.something1: 'im something1'
test.item.something2: 'im something2'
The user is still running on a config.json from before the new update so he only have
test.item.something1: 'im something1'
Why does the etc.
store.get('test.item.something2')
Not return the default value of "i
m something2
" but instead its "undefined
" ?I dont understand the "defaultValue?" extra argument here.
If it's not pulling from the Store's defaults, then what use does it have ?
Or should i really make redundant code like
store.get('test.item.something2','im something2')
If it just looked at the default value you already set via defaults?
PS. Perhaps i'm missing something obviously :)
But i hope you understand my predicament.
The text was updated successfully, but these errors were encountered: