Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
3f4e7c92
Commit
3f4e7c92
authored
Jan 27, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
higher order store functions
parent
c476fa75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
Store.js
src/core/data/store/Store.js
+18
-0
Account.jsx
src/view/page/account/Account.jsx
+1
-1
Login.jsx
src/view/page/login/Login.jsx
+1
-1
No files found.
src/core/data/store/Store.js
View file @
3f4e7c92
...
@@ -143,6 +143,24 @@ Store.prototype = {
...
@@ -143,6 +143,24 @@ Store.prototype = {
},
},
bind
:
function
(
key
)
{
bind
:
function
(
key
)
{
return
new
StoreBinding
(
this
,
key
);
return
new
StoreBinding
(
this
,
key
);
},
val
:
function
(
key
)
{
const
me
=
this
;
return
function
backwardCallback
(
update
)
{
me
.
sub
(
key
,
val
=>
update
(
val
));
}
},
valEqual
:
function
(
key
,
val
)
{
const
me
=
this
;
return
function
backwardCallback
(
update
)
{
me
.
equal
(
key
,
val
,
compareResult
=>
update
(
compareResult
));
}
},
valTrue
:
function
(
key
)
{
return
this
.
valEqual
(
key
,
true
);
},
valFalse
:
function
(
key
)
{
return
this
.
valEqual
(
key
,
false
);
}
}
};
};
const
StoreBinding
=
function
(
store
,
key
){
const
StoreBinding
=
function
(
store
,
key
){
...
...
src/view/page/account/Account.jsx
View file @
3f4e7c92
...
@@ -3,7 +3,7 @@ export default D.declare('view.page.Account', ()=>
...
@@ -3,7 +3,7 @@ export default D.declare('view.page.Account', ()=>
<
div
>
<
div
>
Account Page
Account Page
<
div
>
<
div
>
Hello,
{
_
=>
store
.
sub
(
'account.name'
,
account
=>
_
(
account
)
)
}
Hello,
{
store
.
val
(
'account.name'
)
}
</
div
>
</
div
>
</
div
>
</
div
>
)
)
src/view/page/login/Login.jsx
View file @
3f4e7c92
...
@@ -21,7 +21,7 @@ export default D.declare('view.page.Login', () => {
...
@@ -21,7 +21,7 @@ export default D.declare('view.page.Login', () => {
<
view
.
cmp
.
field
.
LabeledField
label=
{
'Login'
}
bind=
{
loginStore
.
bind
(
'phone'
)
}
/>,
<
view
.
cmp
.
field
.
LabeledField
label=
{
'Login'
}
bind=
{
loginStore
.
bind
(
'phone'
)
}
/>,
<
button
<
button
onclick=
{
()
=>
loginStore
.
set
(
'active'
,
'enterCode'
)
}
onclick=
{
()
=>
loginStore
.
set
(
'active'
,
'enterCode'
)
}
disabled=
{
_
=>
loginStore
.
equal
(
'phoneValid'
,
false
,
_
)
}
disabled=
{
loginStore
.
valFalse
(
'phoneValid'
)
}
>
Ага
</
button
>
>
Ага
</
button
>
],
],
enterCode
:
[
enterCode
:
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment