{"action":"opened","issue":{"url":"https://api.github.com/repos/mobxjs/mobx/issues/286","repository_url":"https://api.github.com/repos/mobxjs/mobx","labels_url":"https://api.github.com/repos/mobxjs/mobx/issues/286/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/mobx/issues/286/comments","events_url":"https://api.github.com/repos/mobxjs/mobx/issues/286/events","html_url":"https://github.com/mobxjs/mobx/issues/286","id":157841362,"number":286,"title":"`action(fn)` stop the autorun when throw an Error","user":{"login":"xiamidaxia","id":4162271,"avatar_url":"https://avatars.githubusercontent.com/u/4162271?v=3","gravatar_id":"","url":"https://api.github.com/users/xiamidaxia","html_url":"https://github.com/xiamidaxia","followers_url":"https://api.github.com/users/xiamidaxia/followers","following_url":"https://api.github.com/users/xiamidaxia/following{/other_user}","gists_url":"https://api.github.com/users/xiamidaxia/gists{/gist_id}","starred_url":"https://api.github.com/users/xiamidaxia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiamidaxia/subscriptions","organizations_url":"https://api.github.com/users/xiamidaxia/orgs","repos_url":"https://api.github.com/users/xiamidaxia/repos","events_url":"https://api.github.com/users/xiamidaxia/events{/privacy}","received_events_url":"https://api.github.com/users/xiamidaxia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-01T07:32:36Z","updated_at":"2016-06-01T07:32:36Z","closed_at":null,"body":"```javascript\r\n\r\n    let autorunTimes = 0;\r\n    class Todos {\r\n      @observable count = 0;\r\n      @action add() {\r\n        this.count ++;\r\n        if (this.count === 2) {\r\n          throw new Error('An Action Error!');\r\n        }\r\n      }\r\n    }\r\n    const todo = new Todos;\r\n    autorun(() => {\r\n      autorunTimes ++;\r\n      return todo.count;\r\n    });\r\n    try {\r\n      todo.add();\r\n      expect(autorunTimes).to.eql(2);\r\n      todo.add();\r\n    } catch (e) {\r\n      todo.add();\r\n      // expect 3 but get 2\r\n      expect(autorunTimes).to.eql(3);\r\n    }\r\n\r\n```"}}
{"actor":{"display_login":"xiamidaxia"}}