[GH-ISSUE #3] Use Redux-saga #5

Closed
opened 2026-03-03 00:17:35 +03:00 by kerem · 1 comment
Owner

Originally created by @Sarah-Seo on GitHub (Nov 20, 2016).
Original GitHub issue: https://github.com/BoostIO/BoostNote-App/issues/3

Dispatch method and database api should be called each data modification.
So, the current code is just like below.

  confirmCreating () {
    const { storageName, storageData } = this.props
    const { store } = this.context

    let count = 0
    let originalName = filenamify(this.state.newName, {replacement: '_'})
    let newName = originalName
    while (storageData.hasIn(['folders', newName])) {
      newName = `${originalName} (${++count})`
    }

    StorageManager
      .upsertFolder(storageName, newName)
      .then((res) => {
        store.dispatch({
          type: 'UPDATE_FOLDER',
          payload: {
            storageName,
            folderPath: newName
          }
        })
      })

    this.setState({
      isCreatingFolder: false
    }, () => {
      this.storageButton.focus()
    })
  }

https://github.com/CarbonStack/Inpad/blob/master/src/main/Nav/StorageSection.js#L101-L129

If we use redux-saga, we just dispatch an action without calling Database API from component.

  confirmCreating () {
    const { storageName, storageData } = this.props
    const { store } = this.context

    let count = 0
    let originalName = filenamify(this.state.newName, {replacement: '_'})
    let newName = originalName
    while (storageData.hasIn(['folders', newName])) {
      newName = `${originalName} (${++count})`
    }

    store.dispatch({
      type: 'ASYNC_UPDATE_FOLDER',
      payload: {
        storageName,
        folderPath: newName
      }
    })

    this.setState({
      isCreatingFolder: false
    }, () => {
      this.storageButton.focus()
    })
  }

It might be included in v1.0. (Not sure)

Originally created by @Sarah-Seo on GitHub (Nov 20, 2016). Original GitHub issue: https://github.com/BoostIO/BoostNote-App/issues/3 Dispatch method and database api should be called each data modification. So, the current code is just like below. ```js confirmCreating () { const { storageName, storageData } = this.props const { store } = this.context let count = 0 let originalName = filenamify(this.state.newName, {replacement: '_'}) let newName = originalName while (storageData.hasIn(['folders', newName])) { newName = `${originalName} (${++count})` } StorageManager .upsertFolder(storageName, newName) .then((res) => { store.dispatch({ type: 'UPDATE_FOLDER', payload: { storageName, folderPath: newName } }) }) this.setState({ isCreatingFolder: false }, () => { this.storageButton.focus() }) } ``` https://github.com/CarbonStack/Inpad/blob/master/src/main/Nav/StorageSection.js#L101-L129 If we use `redux-saga`, we just dispatch an action without calling Database API from component. ```js confirmCreating () { const { storageName, storageData } = this.props const { store } = this.context let count = 0 let originalName = filenamify(this.state.newName, {replacement: '_'}) let newName = originalName while (storageData.hasIn(['folders', newName])) { newName = `${originalName} (${++count})` } store.dispatch({ type: 'ASYNC_UPDATE_FOLDER', payload: { storageName, folderPath: newName } }) this.setState({ isCreatingFolder: false }, () => { this.storageButton.focus() }) } ``` It might be included in v1.0. (Not sure)
kerem closed this issue 2026-03-03 00:17:35 +03:00
Author
Owner

@Sarah-Seo commented on GitHub (Jan 3, 2017):

I tried Redux-saga, but it doesn't seem to be needed for this project.

Because ...

  1. No HMR support
  2. Persist status(Redux store is enough to persist the status)
  3. Require Generator function support(should include babel-runtime)

Instead of it, I applied Redux-thunk.

<!-- gh-comment-id:270043657 --> @Sarah-Seo commented on GitHub (Jan 3, 2017): I tried Redux-saga, but it doesn't seem to be needed for this project. Because ... 1. No HMR support 2. Persist status(Redux store is enough to persist the status) 3. Require Generator function support(should include babel-runtime) Instead of it, I applied Redux-thunk.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/BoostNote-App#5
No description provided.