eventemitter

Angular2: mouse event handling (movement relative to current position)

烈酒焚心 提交于 2019-12-03 11:40:46
问题 My user should be able to move (or rotate) an object by mouse in a canvas. When mouse events occur the screen coordinates are used to calculate the delta (direction and length) to the last event. Nothing special... mousedown (get the first coordinate) mousemove (get nth coordinate, calculate deltaXY, move object by deltaXY) mouseup (same as step 2 and stop the mousemove and mouseup event handling) After this chain of events it should be possible to repeat the same action. This outdated

EventEmitter and Subscriber ES6 Syntax with React Native

守給你的承諾、 提交于 2019-12-03 08:55:50
问题 I am trying to implement an EventEmitter/Subscriber relationship between two components in a react native class. I have seen referenced the following materials: React Native - Event Emitters by Colin Ramsay React Native - Call Function of child from NavigatorIOS These solutions are adequate for what I am trying to accomplish, however, they bother require the use of mixins: [Subscribable.Mixin] on the receiving component to work properly with Subscriber . Unfortunately, I am using ES6 and

Concatenate two (or n) streams

时光毁灭记忆、已成空白 提交于 2019-12-03 05:04:16
问题 2 streams: Given readable streams stream1 and stream2 , what's an idiomatic (concise) way to get a stream containing stream1 and stream2 concatenated ? I cannot do stream1.pipe(outStream); stream2.pipe(outStream) , because then the stream contents are jumbled together. n streams: Given an EventEmitter that emits an indeterminate number of streams, e.g. eventEmitter.emit('stream', stream1) eventEmitter.emit('stream', stream2) eventEmitter.emit('stream', stream3) ... eventEmitter.emit('end')

EventEmitter and Subscriber ES6 Syntax with React Native

本秂侑毒 提交于 2019-12-03 02:57:37
I am trying to implement an EventEmitter/Subscriber relationship between two components in a react native class. I have seen referenced the following materials: React Native - Event Emitters by Colin Ramsay React Native - Call Function of child from NavigatorIOS These solutions are adequate for what I am trying to accomplish, however, they bother require the use of mixins: [Subscribable.Mixin] on the receiving component to work properly with Subscriber . Unfortunately, I am using ES6 and extending my classes from Component so I can not use this mixin syntax. My question is: How can I implement

Angular2: mouse event handling (movement relative to current position)

自闭症网瘾萝莉.ら 提交于 2019-12-03 02:10:27
My user should be able to move (or rotate) an object by mouse in a canvas. When mouse events occur the screen coordinates are used to calculate the delta (direction and length) to the last event. Nothing special... mousedown (get the first coordinate) mousemove (get nth coordinate, calculate deltaXY, move object by deltaXY) mouseup (same as step 2 and stop the mousemove and mouseup event handling) After this chain of events it should be possible to repeat the same action. This outdated example works as expected, after removing the toRx calls. But here the delta to the first coordinate is

Eventemitter and nexttick in nodejs

雨燕双飞 提交于 2019-12-02 16:33:23
问题 I'm confused about Eventemitter. I write a code but that does not work properly. Why the below code does not work : const EventEmitter = require('events'); const util = require('util'); function MyEmitter() { EventEmitter.call(this); this.emit('event'); } util.inherits(MyEmitter, EventEmitter); const myEmitter = new MyEmitter(); myEmitter.on('event', function() { console.log('an event occurred!'); }); // No output! But the below code works? const EventEmitter = require('events'); const util =

Node.js EventEmitter error

萝らか妹 提交于 2019-12-02 12:27:44
I have an error when trying to inherit EvenEmitter /* Consumer.js */ var EventEmitter = require('events').EventEmitter; var util = require('util'); var Consumer = function() {}; Consumer.prototype = { // ... functions ... findById: function(id) { this.emit('done', this); } }; util.inherits(Consumer, EventEmitter); module.exports = Consumer; /* index.js */ var consumer = new Consumer(); consumer.on('done', function(result) { console.log(result); }).findById("50ac3d1281abba5454000001"); /* ERROR CODE */ {"code":"InternalError","message":"Object [object Object] has no method 'findById'"} I've

Node.js event-stream: Where to setMaxListeners?

ⅰ亾dé卋堺 提交于 2019-12-02 04:39:12
I have searched and searched for this, to no avail. I've combed the web (including Stackoverflow), and the Node docs for an answer, and not found one---that worked (maybe that's just bad searching on my part). I'm working with an event-stream in a gulp config file, and I have a particular task that is hitting the classic "memory leak detected" error from the EventEmitter class. From what I've found, the answer to dealing with this issue seems to be to call the setMaxListeners method of the EventEmitter class; and my research has suggested that the event-stream has a Stream object, which should

Toggle property in parent Component from Child Component in Angular2 (similar to $emit in AngularJS)

只愿长相守 提交于 2019-12-01 18:09:48
I'm currently teaching myself Angular2 and I have a practical problem that would be easy to rectify in AngularJS but currently I'm looking through examples to find a solution with Angular2. Anyway, I have a top level component called App and within that component I have a property that applies a css class, here is my HTML that is used as the component template - you can see where I wish to apply the css class using ngClass . The showMenu value is just a boolean. <div class="navigation" role="navigation"> <ul> <li><a [routerLink]="['Home]">Home</a></li> <li><a [routerLink]="['Mail']">Mail</a><

Toggle property in parent Component from Child Component in Angular2 (similar to $emit in AngularJS)

别等时光非礼了梦想. 提交于 2019-12-01 17:58:48
问题 I'm currently teaching myself Angular2 and I have a practical problem that would be easy to rectify in AngularJS but currently I'm looking through examples to find a solution with Angular2. Anyway, I have a top level component called App and within that component I have a property that applies a css class, here is my HTML that is used as the component template - you can see where I wish to apply the css class using ngClass . The showMenu value is just a boolean. <div class="navigation" role=