Flutter How to update data in real time? - flutter

I am using rest apis for getting data but i want to update it in real time, I can't use firebase for the same. please suggest me any better way also calling api again and again is not good idea to achieve it.

For real time you need to use a real time database with a sdk for subscribe to it (like Firebase) or you can use socket.io to stream your data from a standard backend, socket.io is a library to abstract the WebSocket connections.
If you use node for backend i suggest you to read this topic on Nestjs https://docs.nestjs.com/websockets/gateways

Related

Flutter:how to stream mysql database

I am trying to read database continuously but I am not finding any way to do it.First of all I am having a doubt that wether Firebase Realtime Database can do this task with out calling api multiple times.As per I researched over internet to accomplish my task I came to know that socket.io package or web sockets can Abel to complete task but I am trying to find the difference between Firebase Realtime Database and socket.io package which is the best approach to read data in database continuously.If I use socket.io package then how should I connect to my server and what is the procedure can any one explain with example

Publish to Apache Kafka topic from Angular front end

I need to create a solution that receives events from web/desktop application that runs on kiosks. There are hundreds of kiosks spread across the country and each one generate time to time automatic events and events when something happens.
Despite this application is a locked desktop application it is built in Angular v8. I mean, it runs in a webview.
I was researching for scalable but reliable solutions and found Apache Kafka seems to be a great solution. I know there are clients for NodeJS but couldn't find any option for Angular. Angular runs on browser, for this reason, it must communicate to backend through HTTP/S.
In the end, I realized the best way to send events from Angular is to create a API that just gets message from a HTTP/S endpoint and publishes to Kafka topic. Or, is there any adapter for Kafka that exposes topics as REST?
I suppose this approach is way faster than store message in database. Is this statement correct?
Thanks in advance.
this approach is way faster than store message in database. Is this statement correct?
It can be slower. Kafka is asynchronous, so don't expect to get a response in the same time-period you could perform a database read/write. (Again, would require some API, and also, largely depends on the database used)
is there any adapter for Kafka that exposes topics as REST?
Yes, the Confluent REST Proxy is an Apache2 licensed product.
There is also a project divolte/divolte-collector for collecting click-data and other browser-driven events.
Otherwise, as you've discovered, create your own API in any language you are comfortable with, and have it use a Kafka producer client.

Synchronize sending data to the server, whether there is internet or not in Flutter

I am trying to add the temporal feature in my application so that if there is an Internet, the data is sent in the application, and in the absence of the Internet, I keep it and then send it in the event that there is Internet. What should I do about this thing and what is the preferred library to use http or dio
i use dio_http_cache: plugin and it work with me but the best solutions is sqflite or hive

What is the differce between Streams and Sockets in Flutter?

Guys what is the difference between Streams and Sockets in Flutter and when to use them?
I'm going to use Flutter in mobile app(iOS/Android) and the app is going to receive continuous flow of data coming from server, so now I'm confuced what to choose for this purpose.
*Note that performance is important.
Sockets is a real time technology related to server side which enables your back-end to push data to your client side without the need for continuous polling your server.
Streams in flutter is an object that hold reference to changing data that you can tap into it and react to the change.
these are two different concepts but they normally combined together to give you the reactive behavior wanted for your app.
hope that help you.

Advice - Real time data processing from client to server

I am looking for advice/guidance on how to achieve the following:
I have a circuit mounted and connected to an Arduino and I am able to easily retrieve data from it, using Python and the pySerial module. It allows me to determine the value of an analog input over time.
At the moment I am storing that data to a file, with a time stamp and the correspondent value and I would love to hear opinions and thoughts on how I could 'share' this data to a web server and 'play' it live.
Is it possible to 'stream' the values into the dump file and retrieve data from it at the same time through an AJAX request or should I look into event-driven web servers like 'Tornado', 'Twisted'...
I am a bit lost here. Just for the record, I am comfortable with PHP and JavaScript for the final output, I just don't have a clue on how to constantly 'stream' the data I need.
Thanks in advance.
If you don't plan to update the Ardunio device too much then it would make sense to have the Python component continue to collect the data over the serial port and publish it in a way that can easily be consumed by a service which can distribute the information in a more efficient, and probably flexible, manner.
e.g.
read the data from the serial port and publish messages onto a message queue. The message queue can then be read by any other component and the data can then be distributed to other applications/clients.
Make a web call to a server that can process each update and distribute to other applications/clients.
You could use something like Pusher (who I work for) and make a call to the REST API to deliver each message to any connected clients. Whilst this is a good way of distributing your data you will be publishing your data even if no clients are listening so I think you are best to get the data to a component like a web server first.
Assuming you go with 1 or 2, you can then use realtime web solution to distribute the data to any number of clients. You could use Pusher here or you could use a self hosted solution.
So, the data flow as I see it would be:
Ardunio -> small Python app -> Queue (or HTTP request to Web server) -> Realtime Web Technology -> Many clients