INNER CODE UNIT · JavaScript

defaultToObject

fullstackreact/react-native-firestack · lib/firestackModule.js:24

const defaultToObject = child => ({_key: child.key, ...child.val()})
const identity = (i) => i
const defaultSortFn = (a, b) => a.timestamp < b.timestamp
const defaultInitialState = {
  items: [],
}

export class FirestackModule {
  constructor(refName, opts={}) {
    invariant(refName && typeof refName !== 'undefined', 'No ref name passed');
    
    this._refName = refName;
    this._makeRef = opts.makeRef || identity;

    const initialState = Object.assign({}, opts.initialState || defaultInitialState, {
      listening: false,
      items: []
    })

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…