Skip to content

Instantly share code, notes, and snippets.

@khle
Created February 3, 2016 04:48
Show Gist options
  • Select an option

  • Save khle/c410c04069e14a2f8a5a to your computer and use it in GitHub Desktop.

Select an option

Save khle/c410c04069e14a2f8a5a to your computer and use it in GitHub Desktop.
import {Observable} from 'rx';
export function textEntryIntentWithSendButtonClicked(DOMSource) {
const textStream$ = DOMSource.select('#input-msg').events('keyup').map(e => e.target);
const buttonClick$ = DOMSource.select('#send-btn').events('click').map(e => e.target);
return {textStream$, buttonClick$};
}
export function textEntryIntentWithEnterKeyPressed(DOMSource) {
const textStream$ = DOMSource.select('#input-msg').events('keyup').filter(textStream => textStream.keyCode !== 13).map(e => e.target);
const enterKeyPressed$ = DOMSource.select('#input-msg').events('keyup').filter(textStream => textStream.keyCode === 13).map(e => e.target);
return {textStream$, enterKeyPressed$};
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment