Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
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
周韬
node-sample
Commits
04dc782e
Commit
04dc782e
authored
Aug 10, 2016
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweaks
parent
9c56cde1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
Item.vue
src/components/Item.vue
+2
-3
api.js
src/store/api.js
+1
-0
index.js
src/store/index.js
+1
-1
No files found.
src/components/Item.vue
View file @
04dc782e
...
@@ -30,9 +30,8 @@
...
@@ -30,9 +30,8 @@
export
default
{
export
default
{
name
:
'news-item'
,
name
:
'news-item'
,
props
:
[
'item'
],
props
:
[
'item'
],
serverCacheKey
:
({
item
:
{
id
,
__lastUpdated
}
})
=>
{
serverCacheKey
:
props
=>
{
console
.
log
(
__lastUpdated
)
return
`
${
props
.
item
.
id
}
::
${
props
.
item
.
__lastUpdated
}
`
return
`
${
id
}
::
${
__lastUpdated
}
`
}
}
}
}
</
script
>
</
script
>
...
...
src/store/api.js
View file @
04dc782e
...
@@ -50,6 +50,7 @@ function fetch (child) {
...
@@ -50,6 +50,7 @@ function fetch (child) {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
api
.
child
(
child
).
once
(
'value'
,
snapshot
=>
{
api
.
child
(
child
).
once
(
'value'
,
snapshot
=>
{
const
val
=
snapshot
.
val
()
const
val
=
snapshot
.
val
()
// mark the timestamp when this item is cached
val
.
__lastUpdated
=
Date
.
now
()
val
.
__lastUpdated
=
Date
.
now
()
cache
&&
cache
.
set
(
child
,
val
)
cache
&&
cache
.
set
(
child
,
val
)
resolve
(
val
)
resolve
(
val
)
...
...
src/store/index.js
View file @
04dc782e
...
@@ -21,7 +21,7 @@ const store = new Vuex.Store({
...
@@ -21,7 +21,7 @@ const store = new Vuex.Store({
actions
:
{
actions
:
{
// ensure data for rendering given list type
// ensure data for rendering given list type
FETCH_LIST_DATA
:
({
commit
,
dispatch
,
state
,
getters
},
{
type
})
=>
{
FETCH_LIST_DATA
:
({
commit
,
dispatch
,
state
},
{
type
})
=>
{
commit
(
'SET_ACTIVE_TYPE'
,
{
type
})
commit
(
'SET_ACTIVE_TYPE'
,
{
type
})
return
fetchIdsByType
(
type
)
return
fetchIdsByType
(
type
)
.
then
(
ids
=>
commit
(
'SET_LIST'
,
{
type
,
ids
}))
.
then
(
ids
=>
commit
(
'SET_LIST'
,
{
type
,
ids
}))
...
...
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