{"id":212883,"date":"2014-02-18T11:57:03","date_gmt":"2014-02-18T07:57:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=212883"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=212883","title":{"rendered":"<span class=\"post_title\">Declarative event binding \/ handling<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0425\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a CoffeeScript \u0434\u043b\u044f \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u0438\u0441\u0442\u043e\u0440\u0438\u044f<\/h4>\n<p>  \u0423 \u043c\u0435\u043d\u044f 5 \u043b\u0435\u0442 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0432 \u0441\u0435\u0431\u044f .NET (+forms, +WPF, +.NET MVC), Java (+Swing, +Tapestry5, +Groovy), JavaScript (+CoffeeScript, +Node).<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0433\u043e\u0434 \u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0438\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, (\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0447\u044c \u0431\u0443\u0434\u0435\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0445). \u0412\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432 UI, \u044f \u0438\u043c\u0435\u044e \u0434\u0435\u043b\u043e \u0441 \u0434\u0435\u0440\u0435\u0432\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u042f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439, \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Backbone, \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 Google Closure. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u043e\u043f\u044b\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u044e\u0434\u0430 \u0421\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c (Listener pattern).<\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044c\u0421\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0441\u043b\u0438 \u0442\u044b \u0445\u043e\u0442\u0435\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0435\u0433\u043e \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0442\u0435\u0431\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u00ab\u0427\u00bb \u043e\u043d \u043e\u0431\u0445\u043e\u0434\u0438\u043b \u043c\u0430\u0441\u0441\u0438\u0432, \u0438 \u0438\u0441\u043a\u0430\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u00ab\u043d\u0430\u0427\u00bb, \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0435\u0433\u043e. \u0422\u0438\u043f\u0430 \u043a\u0430\u043a \u0432 Swing \/ .NET.<\/p>\n<p>  \u0412\u0441\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u0435\u0439. \u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u0438\u043c\u0435\u043d \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044f\u043c\u0438. \u041f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 \u00ab\u043d\u0430\u0427\u00bb, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u00ab\u0427\u00bb \u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u043e\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u0435\u0439. \u0417\u0430\u0442\u0435\u043c \u0431\u044b\u043b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u0434\u043b\u044f JS, EventEmitter, \u043a\u0430\u043a \u0432 jQuery \/ NodeJS. \u041d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0441\u043e\u0431\u043e \u0437\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u2026<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>SuperEmitter<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0435\u0440\u0435\u0432\u0430 \u00ab\u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044c -&gt; \u0441\u043e\u0431\u044b\u0442\u0438\u044f -&gt; \u0440\u0435\u0430\u043a\u0446\u0438\u0438\u00bb. \u041f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"coffeescript\">class Brain extends SuperEmitter   event_table: [     # \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a    \u0441\u043e\u0431\u044b\u0442\u0438\u0435               \u0440\u0435\u0430\u043a\u0446\u0438\u0438     [ 'ear' , [ [ 'snake_heard'     , [ 'emit_adrenaline'                                         'look_around'        ] ] ] ]     [ 'eye' , [ [ 'food_spotted'    , [ 'emit_noradrenaline'                                         'hunt'                                         'emit_endorphins'    ] ]                 [ 'predator_spotted', [ 'emit_cortisol'                                         'emit_adrenaline'                                         'run'                ] ] ] ]     [ 'nose', [ [ 'food_smelled'    , [ 'look_around'        ] ]                 [ 'blood_smelled'   , [ 'emit_adrenaline'                                         'look_around'        ] ] ] ]   ]    # constructor and instance members   constructor = -&gt;     @ear  = new Ear()     @eye  = new Eye()     @nose = new Nose()    # methods:   emit_adrenaline: -&gt;   emit_cortisol: -&gt;   emit_endorphins: -&gt;   hunt: -&gt;   look_around: -&gt;  new Brain().bind_events() <\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e:  <\/p>\n<pre><code class=\"coffeescript\">class Brain   bind_events: -&gt;     @ear.on 'snake_heard', (args...) =&gt; # \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b       @emit_adrenaline(args...)         # \u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432       @look_around(args...)     @eye.on 'food_spotted', (args...) =&gt;       @emit_noradrenaline(args...)       @hunt(args...)       @emit_endorphins(args...)     @eye.on 'predator_spotted', (args...) =&gt;       @emit_cortisol(args...)       @emit_adrenaline(args...)       @run(args...)     @nose.on 'food_smelled', (args...) =&gt;       @look_around(args...)     @nose.on 'blood_smelled', (args...) =&gt;       @emit_adrenaline(args...)       @look_around(args...)     # \u0438 \u0442.\u0434. <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043c\u043e\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/github.com\/ognivo\/super-emitter\">ognivo\/super-emitter<\/a>. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434, \u0438 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445, \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445 \u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u044f\u0445. \u041a\u043e\u0434\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u043e\u043d \u0447\u0438\u0449\u0435, \u0431\u043e\u043b\u0435\u0435 \u0433\u0440\u0430\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d. \u0424\u043e\u0440\u043c\u0430\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<br \/>  \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435, \u0438 \u0441 \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u044c, \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0447. <\/p>\n<h4>\u0414\u0435\u043c\u043e<\/h4>\n<p>  <a href=\"http:\/\/ognivo.github.io\/\">\u0414\u0435\u043c\u043e \u043e\u043d\u043b\u0430\u0439\u043d<\/a>. \u042d\u0442\u043e \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 demo \u0432 \u0440\u0435\u043f\u043e. \u041c\u043e\u0436\u0435\u0442\u0435 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043e, \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c <\/p>\n<pre><code>npm install super-emitter<\/code><\/pre>\n<p>. \u042f \u0445\u043e\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043d\u043e\u0435 \u0434\u0435\u043c\u043e, \u043d\u043e \u043f\u043e\u043a\u0430 \u0442\u0443\u0433\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c.<\/p>\n<h4>\u0412\u044b\u043f\u0443\u0441\u043a \u0438 \u043f\u0440\u0438\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h4>\n<p>  SuperEmitter \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441. \u0412 \u043d\u0435\u043c \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 emit, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435, \u0447\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<pre><code class=\"coffeescript\">brain = new Brain() brain.bind_events() brain.emit('adrenaline') brain.emit('adrenaline', [dosage_ml = 300, noradrenaline = true])   brain.on 'adrenaline', (dosage_ml, noradrenaline) -&gt;   console.log &quot;I'm running from something&quot;  # OR methods class Brain extends SuperEmitter   emit_adrenaline: (dosage_ml = 10, noradrenaline = true) -&gt;     @emit('adrenaline, [dosage_ml, noradrenaline])   receive_adrenaline: (dosage, noradrenaline) -&gt;     if noradrenaline       console.log &quot;I will fight to death&quot;     else       console.log &quot;Let's get outta here&quot; <\/code><\/pre>\n<h4>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>  \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0448\u044c\u0441\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u00abon\u00bb \u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 (\u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0443\u0441\u0441\u043a\u043e\u0435 \u0441\u043b\u043e\u0432\u043e?) event_name, callback. \u041f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 jQuery \u043e\u0431\u0435\u0440\u0442\u043a\u0438, KineticJS \u0444\u0438\u0433\u0443\u0440\u044b (shapes), \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 SuperEmitter.<\/p>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0434\u043b\u044f DOM-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0442\u043e\u0434 addEventListener \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443, \u0442\u0430\u043a \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0442\u043e\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 popstate \u043e\u0442 \u043e\u043a\u043d\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0435 \u0440\u0435\u0448\u0438\u043b\u043e\u0441\u044c window.on = window.addEventListener.<\/p>\n<h4>\u0427\u0435\u0433\u043e \u043d\u0435\u0442<\/h4>\n<p>  \u041d\u0435\u0442\u0443 \u0432\u0441\u043f\u043b\u044b\u0442\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u0440\u0438\u0447\u0438\u043d \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0438\u0436\u0443, \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u044f \u0432\u0438\u0436\u0443 \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442.<\/p>\n<p>  \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043a\u0440\u0438\u0442\u0438\u043a\u0435, \u043f\u043e\u0445\u0432\u0430\u043b\u0435 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u043c.<br \/>  \u0417.\u042b.: \u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043b \u0441\u043b\u043e\u0432\u043e \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044c, \u0430 \u043d\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/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=\"http:\/\/habrahabr.ru\/post\/212883\/\"> http:\/\/habrahabr.ru\/post\/212883\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0425\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a CoffeeScript \u0434\u043b\u044f \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u0438\u0441\u0442\u043e\u0440\u0438\u044f<\/h4>\n<p>  \u0423 \u043c\u0435\u043d\u044f 5 \u043b\u0435\u0442 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0432 \u0441\u0435\u0431\u044f .NET (+forms, +WPF, +.NET MVC), Java (+Swing, +Tapestry5, +Groovy), JavaScript (+CoffeeScript, +Node).<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0433\u043e\u0434 \u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0438\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, (\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0447\u044c \u0431\u0443\u0434\u0435\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0445). \u0412\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432 UI, \u044f \u0438\u043c\u0435\u044e \u0434\u0435\u043b\u043e \u0441 \u0434\u0435\u0440\u0435\u0432\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u042f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439, \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Backbone, \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 Google Closure. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u043e\u043f\u044b\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u044e\u0434\u0430 \u0421\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c (Listener pattern).<\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044c\u0421\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0441\u043b\u0438 \u0442\u044b \u0445\u043e\u0442\u0435\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0435\u0433\u043e \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0442\u0435\u0431\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u00ab\u0427\u00bb \u043e\u043d \u043e\u0431\u0445\u043e\u0434\u0438\u043b \u043c\u0430\u0441\u0441\u0438\u0432, \u0438 \u0438\u0441\u043a\u0430\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u00ab\u043d\u0430\u0427\u00bb, \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0435\u0433\u043e. \u0422\u0438\u043f\u0430 \u043a\u0430\u043a \u0432 Swing \/ .NET.<\/p>\n<p>  \u0412\u0441\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u0435\u0439. \u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u0438\u043c\u0435\u043d \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044f\u043c\u0438. \u041f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 \u00ab\u043d\u0430\u0427\u00bb, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u00ab\u0427\u00bb \u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u043e\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u0418\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u0435\u0439. \u0417\u0430\u0442\u0435\u043c \u0431\u044b\u043b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u0434\u043b\u044f JS, EventEmitter, \u043a\u0430\u043a \u0432 jQuery \/ NodeJS. \u041d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0441\u043e\u0431\u043e \u0437\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u2026<\/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-212883","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/212883","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=212883"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/212883\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}