{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/mobx/issues/1455","repository_url":"https://api.github.com/repos/mobxjs/mobx","labels_url":"https://api.github.com/repos/mobxjs/mobx/issues/1455/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/mobx/issues/1455/comments","events_url":"https://api.github.com/repos/mobxjs/mobx/issues/1455/events","html_url":"https://github.com/mobxjs/mobx/issues/1455","id":308797462,"number":1455,"title":"Map.delete() function only works with string-type keys?","user":{"login":"dargue3","id":13652794,"avatar_url":"https://avatars1.githubusercontent.com/u/13652794?v=4","gravatar_id":"","url":"https://api.github.com/users/dargue3","html_url":"https://github.com/dargue3","followers_url":"https://api.github.com/users/dargue3/followers","following_url":"https://api.github.com/users/dargue3/following{/other_user}","gists_url":"https://api.github.com/users/dargue3/gists{/gist_id}","starred_url":"https://api.github.com/users/dargue3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dargue3/subscriptions","organizations_url":"https://api.github.com/users/dargue3/orgs","repos_url":"https://api.github.com/users/dargue3/repos","events_url":"https://api.github.com/users/dargue3/events{/privacy}","received_events_url":"https://api.github.com/users/dargue3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-27T02:15:43Z","updated_at":"2018-03-27T06:54:00Z","closed_at":null,"author_association":"NONE","body":"I have a:\r\n\r\n[x] Question:\r\n\r\nI've recently updated to mobx `v4` that includes changes made to `Map`. I've noticed with this new update that in `Map.delete(key)` function, the parameter `key` has to be a string, regardless of what type the key was instantiated with. This is also the case with `Map.get(key)`. Is this a ✨feature ✨of the new Maps? How come?\r\n\r\nFor context, if necessary, I'm referring to mobx-state-tree's implementation of Maps specifically.\r\n\r\ne.g:\r\n```javascript\r\nconst ProductList = t\r\n  .model('Model', {\r\n    map: t.map(Product, {}),\r\n  })\r\n  .actions(self => ({\r\n    add(product) {\r\n      self.map.put({ ...product })\r\n    },\r\n    delete(id) {\r\n      self.map.delete(id);\r\n    },\r\n  }))\r\n\r\nProductList.add({ id: 123 })\r\nProductList.delete(123) // does nothing\r\nProductList.delete('123') // works as intended\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/mobxjs/mobx/issues/comments/376417093","html_url":"https://github.com/mobxjs/mobx/issues/1455#issuecomment-376417093","issue_url":"https://api.github.com/repos/mobxjs/mobx/issues/1455","id":376417093,"user":{"login":"mweststrate","id":1820292,"avatar_url":"https://avatars0.githubusercontent.com/u/1820292?v=4","gravatar_id":"","url":"https://api.github.com/users/mweststrate","html_url":"https://github.com/mweststrate","followers_url":"https://api.github.com/users/mweststrate/followers","following_url":"https://api.github.com/users/mweststrate/following{/other_user}","gists_url":"https://api.github.com/users/mweststrate/gists{/gist_id}","starred_url":"https://api.github.com/users/mweststrate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mweststrate/subscriptions","organizations_url":"https://api.github.com/users/mweststrate/orgs","repos_url":"https://api.github.com/users/mweststrate/repos","events_url":"https://api.github.com/users/mweststrate/events{/privacy}","received_events_url":"https://api.github.com/users/mweststrate/received_events","type":"User","site_admin":false},"created_at":"2018-03-27T06:54:00Z","updated_at":"2018-03-27T06:54:00Z","author_association":"OWNER","body":"Best ask MST related questions in the MST repo :). But short answer, MobX\nmaps support generic keys, but MST maps not, as MST always requires indices\nwhich are serializable *and* suitable to be used as paths.\n\nOp di 27 mrt. 2018 om 04:15 schreef Dan Argue <notifications@github.com>:\n\n> I have a:\n>\n> [x] Question:\n>\n> I've recently updated to mobx v4 that includes changes made to Map. I've\n> noticed with this new update that in Map.delete(id) function, the\n> parameter id has to be a string, regardless of what type the key was\n> instantiated with. Is this a ✨feature ✨of the new Maps or a bug?\n>\n> For context, if necessary, I'm referring to mobx-state-tree's\n> implementation of Maps specifically.\n>\n> e.g:\n>\n> const ProductList = t\n>   .model('Model', {\n>     map: t.map(Product, {}),\n>   })\n>   .actions(self => ({\n>     add(product) {\n>       self.map.put({ ...product })\n>     },\n>     delete(id) {\n>       self.map.delete(id);\n>     },\n>   }))\n> ProductList.add({ id: 123 })ProductList.delete(id) // does nothingProductList.delete(`${id}`) // works as intended\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/mobxjs/mobx/issues/1455>, or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ABvGhFMoZ7w1HCzgcKVliQSnwLvnSi1qks5tiaDWgaJpZM4S8LcV>\n> .\n>\n"}}
{"actor":{"display_login":"mweststrate"}}