realm-react-redux icon indicating copy to clipboard operation
realm-react-redux copied to clipboard

listeners[i] is a not a function

Open jramalho opened this issue 5 years ago • 3 comments

SO guys, the 0.0.9 give me the TypeError: listeners[i] is not a function. Dont know why yet.

jramalho avatar Sep 24 '19 12:09 jramalho

Do you have any more info like a stack trace or some example code?

lamflam avatar Sep 25 '19 00:09 lamflam

is when i instantiate the realm listeners like this:

const listeners = schema.reduce((l, model) => {
    l[model] = (puppies, changes) =>
      InteractionManager.runAfterInteractions(() => {
        const { insertions, modifications } = changes;
        insertions.forEach(i => {
          if (puppies[i] && puppies[i].afterCreate)
            puppies[i].afterCreate(store.dispatch, store.getState);

          if (puppies[i] && puppies[i].afterSave)
            puppies[i].afterSave(store.dispatch, store.getState);
        });
        modifications.forEach(i => {
          if (puppies[i] && puppies[i].afterUpdate)
            puppies[i].afterUpdate(store.dispatch, store.getState);

          if (puppies[i] && puppies[i].afterSave)
            puppies[i].afterSave(store.dispatch, store.getState);
        });
      });

    return l;
  }, {});

jramalho avatar Sep 25 '19 02:09 jramalho

If the crash occurs on listeners[i] then we'd need to see what the listeners object actually looks like after instantiation as well as the value of i when this happens. What is schema in this case?

If you downgrade to 0.0.8 does this work?

If you can set up a small example that reproduces the issue I can run it locally myself to try and find the root cause.

lamflam avatar Sep 25 '19 12:09 lamflam