-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
using the create saga & wondering about the source code here (which is also the same source code for push?):
/**
* Saves new data to the database with `set()`
*
* @param path
* @param fn
* @example
* import { create } from 'firebase-saga';
*
* yield call(create, 'posts', () => ({
* [`posts/1234`]: {
* title: 'My Second Post',
* body: 'Second post details',
* timestamp: +new Date
* }
* })
*);
*/
export function* create(path, fn) {
const key = yield call(newKey, path);
const payload = yield call(fn, key);
const opts = newOpts('error');
const ref = firebase.database().ref();
const [_, { error }] = yield [
call([ref, ref.update], payload, opts.handler),
take(opts)
];
return error;
}
Why does the API require declaring 'posts' as the 2nd arg, and 'posts' in the prop name of the anon set function?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels