Blazored / LocalStorage

A library to provide access to local storage in Blazor applications
https://blazored.github.io/LocalStorage/
MIT License
1.23k stars 117 forks source link

add Exist Method #35

Closed julienGrd closed 5 years ago

julienGrd commented 5 years ago

Hi, and thanks for your work ! can you add an "exist" method on your library ? it's normally not so difficult, something like that

public async Task<bool> Exist(string key)
        {
            if (string.IsNullOrEmpty(key))
                throw new ArgumentNullException(nameof(key));

            var serialisedData = await _jSRuntime.InvokeAsync<string>("localStorage.getItem", key);

            return serialisedData != null;
        }

thanks !

Julien

chrissainty commented 5 years ago

I'll look at getting this added @julienGrd. Also happy to take a PR if you fancy having a go at it?

julienGrd commented 5 years ago

Hi Chris, yeah I can commit this kind of stuff by myself without problem ! By the way, if there is some projects of the blazor community which need helps, i will be happy do help them, i work on blazor since february and I love it, I use a lot of works of the community so it's time to give back to the community (I work at full time so I would do what I can :-) )

julienGrd commented 5 years ago

OK the PR is make, say me if there is something with my code !

julienGrd commented 5 years ago

Solved by https://github.com/Blazored/LocalStorage/pull/37