1

I was trying to jump around documents on line, and i see the set function for when i do set("myString", "hello"); or set("myMap.test", "world"); but i was curious as to what the inverse is? I figured unset but when looking online at the Properties sections of Polymer 1.0 Dart code, i wasnt quite getting the information I wanted.

What is the inverse of set, to remove an attribute? My particular use case is to remove a key from a map, unset("myMap.testKey");

Since set is defined in Polymer_base.dart, i thought it would rest somewhere within that file, but i did not see any "unset" or similar.

1 Answer 1

1

I don't know if it works but I would remove the element from the map and then call

notifyPath('myMap.testKey, null);

If the values was null already then this probably won't work.

6
  • the issue is that I have a computed property which checks for the number of keys in a maintenance map > 0, so ideally if there are no keys, it is ready to go. As the key is resolved, it will remove itself from the map. Even if i define it as undefined the key would be in the map still in this case, no? Jun 14, 2016 at 14:48
  • Seems to be a valid way. See my updated answer. Otherwise just use delete and set("myMap.test", undefined) to get rid of the property and notify Polymer about it. If that causes issues you can try notifyPath(path, value) instead of set(...) (after delete). Jun 14, 2016 at 14:51
  • undefined is a javascript thing, I am writing this in Dart, so perhaps it would just be null? The downside is that even though setting it to undefined, it says it would loop over it still as it is in the map... So that being said maybe my approach of isEnabled => myMap.length == 0; is not the desired approach Jun 14, 2016 at 14:57
  • I see. I didn't notice because it doesn't have the dart tag. Jun 14, 2016 at 14:58
  • 1
    I would always add the dart tag if it is Dart related. More people monitor dart than dart-polymer. Jun 14, 2016 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.