question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Realtime Updates not working

See original GitHub issue

Is the RealtimeRouteMixin working in RC6? I added the Firestore config and a basic layout. I get all data by this.store.findAll('article'). The current state is loaded and displayed correctly. But when I change something in the Firebase console the data is not updated in the Ember client. with version 2.x and the RTDB this was working.

Is this intended or a bug?

Version info

DEBUG: -------------------------------
DEBUG: Ember      : 3.17.0
DEBUG: Ember Data : 3.17.0
DEBUG: EmberFire  : 3.0.0-rc.6
DEBUG: Firebase   : 7.11.0
DEBUG: -------------------------------

Test case

https://github.com/maximilianmeier/emberfire-dev/tree/fd79dce49ed3d610201e6c5b338b60931a6e2f65

Steps to reproduce

  1. Check out the commit.
  2. Add your firebase config
  3. Add data based on Ember Data models
  4. Data should load
  5. Update your data in the Firebase console
  6. The changes are not shown in the Ember app without reloading

Expected behavior

The Data should update without a manual reload.

Actual behavior

The Data does currently not update without a manual reload.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
Mitchalcommented, Apr 3, 2020

So it seems the realtime updates stop working when building the Ember app for production. I guess it might be because the constructor name is then uglified and this code will stop working again. Not really sure how to solve it though, does anyone have any ideas?

EDIT: FOUND IT! 😄 Passing the precious constructor names to uglify to keep them intact, in your ember-cli-build.js like this:

let app = new EmberApp(defaults, {
    'ember-cli-uglify': {
      uglify: {
        mangle: {
          reserved: ['FirestoreSerializer', 'FirestoreAdapter']
        }
      }
    },
  });

Hopefully no more hacks will be required. 🤔

5reactions
Mitchalcommented, Mar 26, 2020

It seems that it comes down to the class names of the adapter and the serializer. I changed from

// adapters/application
import FirestoreAdapter from 'emberfire/adapters/firestore';

export default class ApplicationAdapter extends FirestoreAdapter {
   // ...
}

to

// adapters/application
import FirestoreAdapterBase from 'emberfire/adapters/firestore';

export default class FirestoreAdapter extends FirestoreAdapterBase {
   // ...
}

And I added this serializer, because there was a crash otherwise when creating records:

// serializers/application
import FirestoreSerializerBase from 'emberfire/serializers/firestore';

export default class FirestoreSerializer extends FirestoreSerializerBase {

  normalizeCreateRecordResponse(store, primaryModelClass) {
    let result = super.normalizeCreateRecordResponse(...arguments)
    result.data.type = primaryModelClass.modelName
    return result
  }
}

The class name FirestoreSerializer is important here as well, because it seems to be used within the realtime-listener service.

With these changes, everything seems to work as expected. Does it help at all?

Read more comments on GitHub >

github_iconTop Results From Across the Web

** Troubleshooting ** "Real time updates are not working ...
Real time updates are not working. Please log in again. Cause. There are several known causes for this problem: Scenario #1 - Network...
Read more >
not sure why I'm not receiving realtime updates for a table #1186
I was banging my head against my desk for an hour trying to figure out why it wasn't working, it was returning an...
Read more >
On Dashboard Real time updates are not working for...
Hello, On Dashboard Real time updates are not working for database views. And i'm querying on incident_sla table. kindly suggest. Regards,
Read more >
Firebase web realtime database not updating - Stack Overflow
A quick simple fix is to flag when you're updating the database: isCreatingUser = true; // Flag that we're creating a user firebase...
Read more >
Real Time updates not working - Wisej.com
Real Time updates not working ... I wrote the followng code to update the client every second. This works fine in the window/session...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found