szaranger / firebase-saga

A library for connecting redux-saga middleware to Firebase.
58 stars 15 forks source link

Firebase saga push creates a initial key then pushes to firebase with a different key #23

Open maitham opened 7 years ago

maitham commented 7 years ago

The firebase saga push method, returns a key, however, it returns a key different to the one created on Firebase. I

ORIGINAL

export function* push(path, fn, getKey) {
  const key = yield call(newKey, path);
  const payload = yield call(fn, key);
  const opts = newOpts('error', 'key');
  const ref = firebase.database().ref(path);
  const [_, { error }] = yield [call([ref, ref.push], payload, opts.handler), take(opts)];
  console.log(_, 'METHOD');
  console.log(error, 'ERROR');
  // console.log(key, 'KEY');
  if (getKey && error == undefined) {
    return key;
  }

  return error;
}