{"id":297160,"date":"2020-01-15T09:00:24","date_gmt":"2020-01-15T09:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297160"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297160","title":{"rendered":"\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 RxJS\/Immer \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 Redux\/MobX"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483526\/\">\n<blockquote><p>&#171;\u0412\u044b \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d Flux. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0432\u0430\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0432\u0430\u043c \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.&#187; \u041f\u0438\u0442 \u0425\u0430\u043d\u0442 <\/p><\/blockquote>\n<p>  <img decoding=\"async\" align=\"right\" src=\"https:\/\/habrastorage.org\/webt\/r_\/5f\/tj\/r_5ftjrh0you9eiryn6ae54nwea.png\">  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044f \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e Redux. \u041d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 Action\\Reducer, \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437-\u0437\u0430 \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u0438 \u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u0447\u0435\u0442\u0447\u0438\u043a. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0435\u0433\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435, \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">state = {value: 0}  increase() {    state.value += 1  }  decrease() {   state.value -= 1 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0445\u043e\u0434\u0443 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c MobX, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438\u043c \u0438 \u043d\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u041f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u0441 MobX \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u043e\u0449\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 (\u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 Redux), \u0447\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (\u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 MobX), \u0434\u0430 \u0438 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043a\u0443\u0445\u043d\u044e \u044f \u0431\u044b \u043d\u0435 \u043d\u0430\u0437\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0435\u0436\u0430\u043b\u0430 \u0431\u044b \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432 Angular\\React \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 TypeScript. \u0411\u0435\u0433\u043b\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 github \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u044b\u0434\u0430\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u044c\u043c\u0435\u043c RxJS\/Immer \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0435.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"ispolzuem-rxjs\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c RxJS<\/h1>\n<p>  <\/p>\n<p>\u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u043e\u0437\u044c\u043c\u0435\u043c <code>BehaviorSubje\u0441t<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>{value: 0} -&gt; {value: 1} -&gt; {value: 2}<\/code> \u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>getValue<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c API <code>BehaviorSubject<\/code> \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043c Redux<\/p>\n<p>  <\/p>\n<ul>\n<li><code>getValue() \/ getState() \/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/code><\/li>\n<li><code>subscribe() \/ subscribe() \/\/ \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u043e \u043d\u043e\u0432\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438<\/code><\/li>\n<li><code>next(value) \/ dispatch(action), replaceReducer(nextReducer) \/\/ \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u0432\u043e\u0435<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043a\u0430\u043a \u0440\u0430\u0437 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 <code>BehaviorSubject<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>Action\/Reducer<\/code> \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>next()<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><strong>CounterService V1<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class CounterServiceV1 {   state = new BehaviorSubject({value: 0})    increase() {     this.state.next({value: this.state.value.value + 1})   }    decrease() {     this.state.next({value: this.state.value.value - 1})   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0433\u043b\u0430\u0437\u0430 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u0438\u0437 <code>this.state.next<\/code> \u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 <code>state.value += 1<\/code><\/p>\n<p>  <\/p>\n<h1 id=\"dobavlyaem-immer\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Immer<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Immer. Immer \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\"> const state = {value: 0} \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0440\u0430\u0444\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f const draft = createDraft(state) \/\/ \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0441 \u043d\u0438\u043c \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f draft.value += 1 \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 const newState = finishDraft(draft)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"svyazka-behaviorsubject-i-immer\">\u0421\u0432\u044f\u0437\u043a\u0430 BehaviorSubject \u0438 Immer<\/h3>\n<p>  <\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>BehaviorSubject<\/code> \u0438 Immer \u0432 \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>RxState<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class RxState&lt;TState&gt; {   private subject$: BehaviorSubject&lt;TState&gt;   private currentDraft?: Draft&lt;TState&gt;    get state() {     return this.subject$.value   }    get state$() {     return this.subject$   }    get draft(): Draft&lt;TState&gt; {     if (this.currentDraft !== undefined) {       return this.currentDraft     }     throw new Error(\"draft doesn't exists\")   }    constructor(readonly initialState: TState) {     this.subject$ = new BehaviorSubject(initialState)   }    public updateState(recipe: (draft: Draft&lt;TState&gt;) =&gt; void) {     let topLevelUpdate = false \/\/ \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 updateState     if (!this.currentDraft) {       this.currentDraft = createDraft(this.state)       topLevelUpdate = true     }     recipe(this.currentDraft)     if (!topLevelUpdate) {       return     }     const newState = finishDraft(this.currentDraft, () =&gt; {}) as TState     this.currentDraft = undefined     if (newState !== this.state) {       this.subject$.next(newState)     }   }  }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>RxState<\/code>, \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c <code>CounterService<\/code>:<\/p>\n<p>  <\/p>\n<p><strong>CounterService V2<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class CounterServiceV2 {   state = new RxState({value: 0})    increase() {     this.state.updateState(draft =&gt; {       draft.value += 1     })   }    decrease() {     this.state.updateState(draft =&gt; {       draft.value -= 1     })   } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Diff<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">-  state = new BehaviorSubject({value: 0}) +  state = new RxState({value: 0})     increase() { -    this.state.next({value: this.state.value.value + 1}) +    this.state.updateState(draft =&gt; { +      draft.value += 1 +    })    }     decrease() { -    this.state.next({value: this.state.value.value - 1}) +    this.state.updateState(draft =&gt; { +      draft.value -= 1 +    })    }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430, \u043d\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>updateState<\/code>. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u0438 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>SimpleImmutableStore<\/code>, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0434\u043b\u044f \u0441\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class SimpleImmutableStore&lt;TState&gt; {    rxState!: RxState&lt;TState&gt;    get draft() {     return this.rxState.draft   }    constructor(initialState: TState) {     this.rxState = new RxState&lt;TState&gt;(initialState)   }    public updateState(recipe: (draft: Draft&lt;TState&gt;) =&gt; void) {     this.rxState.updateState(recipe)   }  }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0442\u043e\u0440 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e:<\/p>\n<p>  <\/p>\n<p><strong>CounterStore V1<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class CounterStoreV1 extends SimpleImmutableStore&lt;{value: number}&gt; {   constructor(){     super({value: 0})   }    increase() {     this.updateState(() =&gt; {       this.draft.value += 1     })   }    decrease() {     this.updateState(() =&gt; {       this.draft.value -= 1     })   } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Diff<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">-class CounterServiceV2 { -  state = new RxState({value: 0}) +class CounterStoreV1 extends SimpleImmutableStore&lt;{value: number}&gt; { +  constructor(){ +    super({value: 0}) +  }     increase() { -    this.state.updateState(draft =&gt; { -      draft.value += 1 +    this.updateState(() =&gt; { +      this.draft.value += 1      })    }     decrease() { -    this.state.updateState(draft =&gt; { -      draft.value -= 1 +    this.updateState(() =&gt; { +      this.draft.value -= 1      })    }  } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 <code>this.updateState<\/code>. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0432\u044b\u0437\u043e\u0432 <code>updateState<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const wrapped = Symbol() \/\/ \u0414\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0434\u0432\u043e\u0439\u043d\u043e\u0433\u043e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f  function getMethodsNames(constructor: any) {   const names = Object.getOwnPropertyNames(constructor.prototype).filter(     x =&gt; x !== \"constructor\" &amp;&amp; typeof constructor.prototype[x] === \"function\",   )   return names }  function wrapMethodsWithUpdateState(constructor: any) {   if (constructor[wrapped]) {     return   }   constructor[wrapped] = true   for (const propertyName of getMethodsNames(constructor)) {     const descriptor = Object.getOwnPropertyDescriptor(       constructor.prototype,       propertyName,     )!      const method = descriptor.value     descriptor.value = function(...args: any[]) {       const store = this as SimpleImmutableStore&lt;any&gt;       let result: any       store.updateState(() =&gt; { \/\/ \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 updateState         result = method.call(store, ...args)       })       return result     }     Object.defineProperty(constructor.prototype, propertyName, descriptor)   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 (\u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430)<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">  constructor(initialState: TState ) {     this.rxState = new RxState&lt;TState&gt;(initialState)     wrapMethodsWithUpdateState(this.constructor)   }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>CounterStore<\/strong><\/p>\n<p>  <\/p>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u0442\u043e\u0440\u0430. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 <code>decrease<\/code> \u0438 \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>setValue<\/code> \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e <code>increaseWithDelay<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class CounterStore extends SimpleImmutableStore&lt;{ value: number }&gt; {    constructor() {     super({value: 0})   }    increase() {     this.draft.value += 1   }    decrease() {     const newValue = this.draft.value - 1     if (newValue &gt;= 0) {       this.draft.value = newValue     }   }    setValue(value: number) {     this.draft.value = value   }    increaseWithDelay() {     setTimeout(() =&gt; this.increase(), 300)   } }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"ispolzovanie-s-angular\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 Angular<\/h1>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0441\u0442\u043e\u0440\u0430 \u043b\u0435\u0436\u0438\u0442 RxJS, \u0442\u043e \u0441 Angular \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 <code>async<\/code> pipe:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;div *ngIf=\"store.rxState.state$ | async as state\"&gt;   &lt;span&gt;{{state.value}}&lt;\/span&gt;   &lt;button (click)=\"store.increase()\"&gt;+&lt;\/button&gt;   &lt;button (click)=\"store.decrease()\"&gt;-&lt;\/button&gt;   &lt;button (click)=\"store.setValue(0)\"&gt;Reset&lt;\/button&gt;   &lt;button (click)=\"store.increaseWithDelay()\"&gt;Increase with delay&lt;\/button&gt; &lt;\/div&gt;<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"demohttpsstackblitzcomeditangular-yywqyifilesrc2fapp2fappcomponentts\"><a href=\"https:\/\/stackblitz.com\/edit\/angular-yywqyi?file=src%2Fapp%2Fapp.component.ts\" rel=\"nofollow\">Demo<\/a><\/h2>\n<p>  <\/p>\n<h1 id=\"ispolzovanie-s-react\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 React<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f React \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 hook:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function useStore&lt;TState, TResult&gt;(   store: SimpleImmutableStore&lt;TState&gt;,   project: (store: TState) =&gt; TResult, ): TResult {   const projectRef = useRef(project)   useEffect(() =&gt; {     projectRef.current = project   }, [project])    const [state, setState] = useState(projectRef.current(store.rxState.state))    useEffect(() =&gt; {     const subscription = store.rxState.state$.subscribe(value =&gt; {       const newState = projectRef.current(value)       if (!shallowEqual(state, newState)) {         setState(newState)       }     })     return () =&gt; {       subscription.unsubscribe()     }   }, [store, state])    return state }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const Counter = () =&gt; {   const store = useMemo(() =&gt; new CounterStore(), [])   const value = useStore(store, x =&gt; x.value)   return (     &lt;div className=\"counter\"&gt;       &lt;span&gt;{value}&lt;\/span&gt;       &lt;button onClick={() =&gt; store.increase()}&gt;+&lt;\/button&gt;       &lt;button onClick={() =&gt; store.decrease()}&gt;-&lt;\/button&gt;       &lt;button onClick={() =&gt; store.setValue(0)}&gt;Reset&lt;\/button&gt;       &lt;button onClick={() =&gt; store.increaseWithDelay()}&gt;Increase with delay&lt;\/button&gt;     &lt;\/div&gt;   ) }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"demohttpsstackblitzcomeditreact-ts-jfudwqfileindextsx\"><a href=\"https:\/\/stackblitz.com\/edit\/react-ts-jfudwq?file=index.tsx\" rel=\"nofollow\">Demo<\/a><\/h2>\n<p>  <\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0435\u0439: middleware, state slicing, update rollback \u2014 \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0421 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0442\u0430\u043a\u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435 <strong><a href=\"https:\/\/github.com\/simmor-store\/simmor\" rel=\"nofollow\">https:\/\/github.com\/simmor-store\/simmor<\/a><\/strong><\/p>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0437\u0430 \u043b\u044e\u0431\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/483526\/\"> https:\/\/habr.com\/ru\/post\/483526\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483526\/\">\n<blockquote><p>&#171;\u0412\u044b \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d Flux. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0432\u0430\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0432\u0430\u043c \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.&#187; \u041f\u0438\u0442 \u0425\u0430\u043d\u0442 <\/p><\/blockquote>\n<p>  <img decoding=\"async\" align=\"right\" src=\"https:\/\/habrastorage.org\/webt\/r_\/5f\/tj\/r_5ftjrh0you9eiryn6ae54nwea.png\">  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044f \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e Redux. \u041d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 Action\\Reducer, \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437-\u0437\u0430 \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u0438 \u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u0447\u0435\u0442\u0447\u0438\u043a. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0435\u0433\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435, \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">state = {value: 0}  increase() {    state.value += 1  }  decrease() {   state.value -= 1 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0445\u043e\u0434\u0443 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c MobX, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438\u043c \u0438 \u043d\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u041f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u0441 MobX \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u043e\u0449\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 (\u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 Redux), \u0447\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (\u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 MobX), \u0434\u0430 \u0438 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043a\u0443\u0445\u043d\u044e \u044f \u0431\u044b \u043d\u0435 \u043d\u0430\u0437\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0435\u0436\u0430\u043b\u0430 \u0431\u044b \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432 Angular\\React \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 TypeScript. \u0411\u0435\u0433\u043b\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 github \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u044b\u0434\u0430\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u044c\u043c\u0435\u043c RxJS\/Immer \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0435.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-297160","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297160"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297160\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}