1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

debounce dispatch

This commit is contained in:
Dick Choi
2016-07-26 01:13:08 +09:00
parent d73b567bd4
commit 65e1a39027
2 changed files with 20 additions and 16 deletions

View File

@@ -89,15 +89,17 @@ class MarkdownNoteDetail extends React.Component {
}
save () {
let { note, dispatch } = this.props
clearTimeout(this.saveQueue)
this.saveQueue = setTimeout(() => {
let { note, dispatch } = this.props
dispatch({
type: 'UPDATE_NOTE',
note: this.state.note
})
dispatch({
type: 'UPDATE_NOTE',
note: this.state.note
})
dataApi
.updateNote(note.storage, note.folder, note.key, this.state.note)
dataApi
.updateNote(note.storage, note.folder, note.key, this.state.note)
}, 1000)
}
handleFolderChange (e) {

View File

@@ -99,15 +99,17 @@ class SnippetNoteDetail extends React.Component {
}
save () {
let { note, dispatch } = this.props
clearTimeout(this.saveQueue)
this.saveQueue = setTimeout(() => {
let { note, dispatch } = this.props
dispatch({
type: 'UPDATE_NOTE',
note: this.state.note
})
dispatch({
type: 'UPDATE_NOTE',
note: this.state.note
})
dataApi
.updateNote(note.storage, note.folder, note.key, this.state.note)
dataApi
.updateNote(note.storage, note.folder, note.key, this.state.note)
}, 1000)
}
handleFolderChange (e) {