funkensturm/ember-local-storage

[Feature Request] Sets

Closed this issue · 5 comments

I just discovered and love this addon. I'm successfully using the array component ... but then realized I actually need uniqueness and have application logic to ensure just that. However, my app could/will be simpler when a Set type becomes available 😬

ids as strings (and then I have a computed property that observes the storage array and fetches the actual records)

@jmonster If you use .addObject('123') it should check for uniqueness. See the docs: https://www.emberjs.com/api/ember/3.7/classes/MutableArray/methods/addObject?anchor=addObject

obj * object to add, if not already present

Welp... thank you so much haha :) I wonder if that makes adding an O(n) operation then? Or if a Set is maintained internally to track uniqueness?

Might be cool to add a Set that just remaps push to add? That way you could still get some of the other Set properties (most importantly for me, O(1) lookups)

Anyway, thank you kindly! Much appreciated.

Closing this for now. If you are interested in implementing a Set you are welcome to reopen it.