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.

Change of screen with observables

See original GitHub issue

I have an application, with login screen, choice of company and dashboard.

I had a redux structure that on my routes I did something like:

  if (signedUser) {
    if (signedCompany) {
      return <AppRoutes />;
    }
    return <CompanyRoutes />;
  }

  return <AuthRoutes />;

It worked well, as it was with reducer and it redirected itself to the route if it changed these variables.

With the use of Watermelon, I tried to use getLocal, but it does not observe the variables as it is in the documentation.

So, I had to make an ‘auth’ scheme and model and put the columns ‘signed_user’, ‘signed_company’ to make it observable, the only way I thought to make it observable, this table would have only one record.

At login, create the record, and when choosing a company, update the record.

In my routes it is:

const enhance = withObservables(['auth'], ({ database }) => ({
  auth: database.get('auth').query().observe(),
}));

export default withDatabase(enhance(Routes));

I happen to be looking at a list, and when it updates the record, it doesn’t.

How would you observe the update of the first record?

I tried to do otherwise, at login, create a user with id: ‘00000000-0000-0000-0000-000000000001’

And on the routes it would look like:

  auth: database.get('auth').findAndObserve('00000000-0000-0000-0000-000000000001').observe(),

But the routes happen before and there is a registration error not found because it has not yet been created.

So, I would have to add this single record to the auth after creating the database. But I saw that it doesn’t have this native and I saw an issue that needs to do several things to create a database with preloading, as I’m new to this tool, I didn’t understand almost anything.

If anyone can help me, because something that seemed to be easy, is leaving me with no options.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
jrounsavcommented, Mar 2, 2021

database.get(‘auth’).observeWithColumns

@osvaldokalvaitir I think you need to query. database.get('auth').query().observeWithColumns()

1reaction
osvaldokalvaitircommented, Mar 3, 2021

@jrounsav thank you so much! That was what was missing =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular View Updating Using Observables, Behavior Subject ...
Angular has an awesome built-in feature for updating views dynamically known as Change Detection. Essentially, when an event occurs, ...
Read more >
Using an Observable to detect a change in a variable
Let's say I just have a string variable, and when it changes, it fires off any subscriptions. javascript · rxjs · observable ·...
Read more >
Work with observable data objects - Android Developers
If the base class for data classes cannot be changed, the Observable interface can be implemented using a PropertyChangeRegistry object to register and...
Read more >
Simplifying Angular Change Detection - Telerik
The change detector checks the component for the data change and re-renders the view to project the updated data. When Change Detector Runs....
Read more >
Observable in Angular 13 | auto refresh after database update
Your browser can't play this video. Learn more. Switch camera.
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