Skip to content

Default Value option for 'get' function. - #247

Open
mmcrockett wants to merge 6 commits into
grevory:masterfrom
mmcrockett:master
Open

mmcrockett wants to merge 6 commits into
grevory:masterfrom
mmcrockett:master

Conversation

@mmcrockett

Copy link
Copy Markdown

I noticed @ayman-alkom created some pull requests with the same idea but it seems it never got completed. I followed the same idea but added the necessary test cases.

I chose not to store the default value since I felt this violated a principle of 'get' shouldn't do any saving of data. I don't have a strong opinion on this and I created test cases that explicitly show this assumption so it can easily be changed.

@eymen-elkum

Copy link
Copy Markdown

Hi @mmcrockett
It seems that this feature is required, but if the default value will not be saved then we can replace the PR with this simple script:
var variable = localStorageService.get('key') || default_val;

@ghost

ghost commented Nov 8, 2016

Copy link
Copy Markdown

What's up here?

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

Successfully merging this pull request may close these issues.

2 participants