Where is the best place to initialize a database in Flutter - database

Im creating a chat app. And wondered. Where is the best place to initialize the database. I am using firebase. I just started thinking about it, as it doesn't seem like the best practice to initialize it with a singleton and then update it via states. I would be grateful for help
I tried create singleton and updating from states. But its really bad, just copypast in the end

Related

Is there any way to connect directly to a database with react js?

I am coding simple CRUD application and would love to avoid backend (including PHP). Is there any way i could do it? If you have an idea that uses backend but still it's easy to initialize could you explain it to me please?
I have a folder with my simple CRUD application and I'm using only css,html and react.js
I have tried express but probably wrong and pgPool. I would love to connect directly somehow. Thing that i am trying to avoid the most is PHP
I haven't decided if i want to use mySQL or postgre yet, so im fully flexible with coice.

Make the admin dashboard in the right way

I use Yii2, ReactJS and Redux in my project. So, client side is good and beautiful, but current admin panel is the most ugly thing in the world (legacy). My goal is create new one.
How can I make admin dashboard using my stack?
My needs:
Modular structure
Individual structure of the state of each module
Write frontend fully on React and make it interactive (React Router?)
Not only CRUD. Some sections may be only informative, with some buttons and checkboxes. Or reports. Or for other purposes. (dont think that REST is only one thing that I need)
Don't wanna store all of DB records in the global redux state. But wanna load all records and other information by need (Depending on the page, sections, current state etc). And it should automatically clean off the state once I change page.
Maybe there's something else that I don't know yet..)
I need advice from professionals. Maybe articles or good libraries that can help me. I'll be very grateful.
P.S.This question is all about how to connect backend and frontend and keep state clean. Not about UX or UI
P.P.S. Sorry for my "Russian" English. Hope you'll understand me :)

Firebase to Wordpress

I'm new to WordPress and I've also been having fun experimenting with Angular/Firebase.
I'm looking to find a way to have an Angular app connect with the WP API in a way that goes further than just displaying posts.
Can someone direct me towards how to submit a form to Firebase and have it simultaneously create a new post and/or page in the WordPress backend? I've come across Zapier but, a) It doesn't seem to be flexible enough for what I want to do and b) It's not free and I'd rather figure it out on my own (with some help from you guys of course.)
I'm plenty fine with being able to use an $http request to list and display posts... but how can I create NEW posts?
PS: I don't NEED to use Firebase. Mainly, I'm really most concerned with creating a new post and/or comment without having to actually do it from the wp-admin.

Using 2 views and sharing data in AngularJS

Im trying to share data between 2 views. I need to use the 2 views at the same time on two different machines. One is controlling the other(ex: a counter) 1st view has next(+1) and the other just displays the result. I want the data to synchronized/binded. I do not want to have to refresh the 2nd page or to have to pull data with a timer or otherwise.
My idea was to use ng-view and routeProvider, I know that when the view changes the scope is cleared so I tried to use a parent controller/scope, the data is shared but I have to refresh the page on my 2nd view. I tried a service, same thing. I tried to $watch the result of the service but on the second controller/view no event is picked up so the view doesn't update.
what is the way to go? I was thinking about broadcasting or emit a custom event and trying to catch it, will that work? Am I just not binding to the service correctly? Would ui-router work better? I feel there should be an easy way to do this.... Im not seeing it! Please help if you can.
One of the simplest (in my opinion) implementations of client-client communication is using WebSockets. While that does have compatibility limitations (some browsers), that can easily be overcome by using a library like socket.io. Also, it's easy to write an Angular wrapper/service over socket.io that can be shared across components of your app, or even different modules.
It's also pretty simple to write a Node backend with socket.io
This might be a good read.
I would suggest you to focus on pushing stream rather than sharing it. Some how you need to push stream to second view which is changes in first view.
You may want to check this
Is there some way to PUSH data from web server to browser?

How to create a dynamic front end based on Node JS, MongoDB, Sails JS

Basically I'm writing an app and am using Sails, MongoDB and Node JS for the back end. I'll use Sail's API features and was wondering what would be the best way to make the app realtime.
For instance I could use AJAX to call the API and manipulate the DOM using jQuery and update the DB through $.post then let the model update the db in the backend, however I'm finding this approach quite cumbersome. Not to mention I can see the code could become quite difficult to maintain after a while.
I've been doing some research and - if I understood correctly - it seems I could use either Backbone, Angular or Knockout to manipulate the data/DOM on the front end, however I'm not sure what would be the best approach in my case nor whether any of these would indeed suit my needs:
Being able to get the data dynamically
Update the data and the DOM dynamically as the user interact with the page
Post the updated data dynamically with none or as minimal data transformation on the back end as possible
All the above asynchronously
As I don't want this to become a heated debate on which library is best, so I would like to know only whether any of the aforementioned libraries can do what I need and which is the leanest/simplest/has the lighter learning curve.
I did similar research a while ago and when found AngularJS, just stopped looking any further.
Right to your questions:
Being able to get the data dynamically
It is pure pleasure to do it in Angular. For the very basic functionality you have got $http service which allows you to send http request and register a callback when the data arrives.
For more complicated things there are modules ngResource and Restangular (external).
Update the data and the DOM dynamically as the user interact with the page
For manipulating DOM, Angular introduced concept of directive. It is basically future of the web (Shodow DOM and Web Components) right now. At this time point, there is nothing more elegant out there.
Post the updated data dynamically with none or as minimal data transformation on the back end as possible
Yes. JSON.
All the above asynchronously.
Yes, of course.
SailsJS provides interchangeability of HTTP or socket.io connections. In your case I think sockets would be a better fit than AJAX.

Resources