Closed jaumard closed 6 years ago
Hi,
Adapter
is immutable. You have to maintain a connection per user resulting in one adapter per connection which in turn resulting in a bean per connection.
Hum that will not work for me... it will basically be equal to just restart the app from scratch for each user... Bean are not singleton so you can have references of them everywhere in the app... only way you're sure there no reference in some redux middleware it to restart from scratch... One way that I could achieve that on my side would be to change the internal use of _connexion to the public getter "connection". Like this it will allow my to override the adapter and do this switchDatabase.
Is that changes ok for you then ?
just pushed that changes and remove switchDatabase, let me know if it's ok for you like this @tejainece :) I'll do it on my side
Little story about this :)
In our app we need one database per user, so each time there a login we need to switch the database to another one. Problem with the current way of working of jaguar is that the Apater is needed in every "Bean" so if we want to switch database we need to switch Adapter, meaning recreate every "Bean" that are in multiple place of the app... so it's not really doable/safe to switch the adapter as reference can be kept in other objects. Instead what we can if switch the underlying connection to a new one each time the user login. That why
switchDatabase
is useful