Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3dea0b

Browse files
committed
add comments
1 parente9b139b commita3dea0b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎src/components/Todos/intent.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,52 @@
11
import{Observable}from'rx';
22
import{ENTER_KEY,ESC_KEY}from'../../utils';
33

4+
// THE INTENT FOR THE LIST
45
exportdefaultfunctionintent(DOM,hashchange,initialHash,itemAction$){
56
return{
7+
// THE ROUTE STREAM
8+
// The stream of the initial hash is being concatenated with
9+
// the hashchange stream.
610
changeRoute$:Observable.concat(
711
initialHash.map(hash=>hash.replace('#','')),
812
hashchange.map(ev=>ev.newURL.match(/\#[^\#]*$/)[0].replace('#',''))
913
),
1014

15+
// CLEAR INPUT STREAM
16+
// A stream of ESC key strokes in the `.new-todo` field.
1117
clearInput$:DOM.select('.new-todo').events('keydown')
1218
.filter(ev=>ev.keyCode===ESC_KEY),
1319

20+
// ENTER KEY STREAM
21+
// A stream of ENTER key strokes in the `.new-todo` field.
1422
insertTodo$:DOM.select('.new-todo').events('keydown')
23+
// Trim value and only let the data through when there
24+
// is anything but whitespace in the field and the ENTER key was hit.
1525
.filter(ev=>{
1626
consttrimmedVal=String(ev.target.value).trim();
1727
returnev.keyCode===ENTER_KEY&&trimmedVal;
1828
})
29+
// Return the trimmed value.
1930
.map(ev=>String(ev.target.value).trim()),
2031

32+
// TOGGLE STREAM
33+
// Create a stream out of all the toggle actions on the todo items.
2134
toggleTodo$:itemAction$.filter(action=>action.type==='toggle'),
2235

36+
// DELETE STREAM
37+
// Create a stream out of all the destroy actions on the todo items.
2338
deleteTodo$:itemAction$.filter(action=>action.type==='destroy'),
2439

40+
// EDIT STREAM
41+
// Create a stream out of all the doneEdit actions on the todo items.
2542
editTodo$:itemAction$.filter(action=>action.type==='doneEdit'),
2643

44+
// TOGGLE ALL STREAM
45+
// Create a stream out of the clicks on the `.toggle-all` button.
2746
toggleAll$:DOM.select('.toggle-all').events('click'),
2847

48+
// DELETE COMPLETED TODOS STREAM
49+
// A stream of click events on the `.clear-completed` element.
2950
deleteCompleteds$:DOM.select('.clear-completed').events('click')
3051
};
3152
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp