示例#1
0
 return new Promise((resolve, reject) => {
   instance[method](args, (error, data) => {
     if (error) {
       reject(error)
     } else {
       resolve(data)
     }
   })
 })
示例#2
0
文件: firebase.js 项目: t0t/refire
    return new Promise((resolve, reject) => {

      const id = uuid.v4()
      const finalPath = typeof path === "function"
        ? path(getState(), ownProps)
        : path

      dispatch(
        updateWriteProcessing({
          path: finalPath,
          id: id,
          value: true
        })
      )

      const url = `${getState().firebase.url}${finalPath}`
      const ref = new Firebase(url)
      ref[method](
        value,
        error => {
          if (error) {
            dispatch(
              updateWriteErrors(finalPath, error.message)
            )
            return reject()
          }
          dispatch(
            updateWriteProcessing({
              path: finalPath,
              id: id,
              value: false
            })
          )
          return resolve()
        }
      )
    })