logo
down
shadow

I need to do a firebase stream and not a Http Get


I need to do a firebase stream and not a Http Get

By : user3099857
Date : January 11 2021, 05:14 PM
wish help you to fix your issue i'm trying to use bloc pattern in flutter but i'm getting some issues because i need to get the data in realtime but with the bloc that i have i only get the data when update the app because bloc use Http Get and i need to use Stream , can any one help me ? , create a new file and name it database.dart
database.dart
code :
abstract class Database {
  Stream<ProyectoModel> countersStream();
}

class AppFirestore implements Database {
    static final String rootPath = 'Users';
    Stream<ProyectoModel> countersStream() {
        turn _DatabaseStream<Proyectos>(
            apiPath: rootPath,
            parser: _DatabaseCountersParser(),
        ).stream;
    };
}

class _DatabaseStream<T> {
  _DatabaseStream({String apiPath, DatabaseNodeParser<T> parser}) {
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.instance;
    DatabaseReference databaseReference =
        firebaseDatabase.reference().child(apiPath);
    var eventStream = databaseReference.onValue;
    stream = eventStream.map((event) => parser.parse(event));
  }

  Stream<T> stream;
}

abstract class DatabaseNodeParser<T> {
  T parse(Event event);
}

class _DatabaseCountersParser implements DatabaseNodeParser<ProyectoModel> {
  ProyectoModel parse(Event event) {
    Map<dynamic, dynamic> values = event.snapshot.value;
    if (values != null) {
      Iterable<String> keys = values.keys.cast<String>();

      var model = keys
          .map((key) => ProyectoModel(id: int.parse(key), name: values["name"]))
          .toList();
      model.sort((lhs, rhs) => rhs.id.compareTo(lhs.id));
      return model;
    } else {
      return [];
    }
  }
}
var database = AppFirestore();
var stream = database.countersStream();

StreamBuilder(
    stream:stream,
    builder:(contex.snapshot){
        if(snapshot.hasData){
            return ProyectoModel.fromJson(snapshot.data.value);
        }
    },
);


Share : facebook icon twitter icon
do you think http protocol mix character stream with byte stream is not a good design

do you think http protocol mix character stream with byte stream is not a good design


By : jfilgairacordon
Date : March 29 2020, 07:55 AM
Any of those help It is not just bad design ... it is broken. The chances are that the BufferedReader will read the first part of the request body into its buffer. So when you read from the stream at the end, you won't get all of the body.
Once you have wrapped an InputStream you shouldn't use it directly ... especially if the wrapper does buffering.
Difference between returning a Stream and writing to HTTP output stream

Difference between returning a Stream and writing to HTTP output stream


By : Martins
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I resolved my issue with two changes.
I took what carlosfiguera said and changed HttpContext.Current.Response.AddHeaders(...) to WebOperationContext.Current.OutgoingResponse.Add(...) In my WebConfig I located the binding tag my service had it's bindingCOnfiguration set to and changed transferMode to "Streamed"
How to stream XML from SQL Server 2005 to HTTP Response stream for download

How to stream XML from SQL Server 2005 to HTTP Response stream for download


By : MD Paris
Date : March 29 2020, 07:55 AM
will be helpful for those in need Something like this has been working for me for a while. Note you'll have to tailor it to your situation:
code :
var settings = new XmlWriterSettings {
    // your settings
};

using (var xmlWriter = XmlWriter.Create(response.Output, settings))
using (var connection = YourConnection())
using (var command = CreateCommand(sql, connection, dbParams) as SqlCommand )
{
    try {
        connection.Open();
        using (var reader = command.ExecuteXmlReader())
        {
            while (reader.Read())
                xmlWriter.WriteNode(reader, true);
        }
    }
    catch ( Exception ex )
    {
        // log, whatever
        throw;
    }
}
Flutter Firebase: How to remove firebase listener when using stream builder?

Flutter Firebase: How to remove firebase listener when using stream builder?


By : Afendi Andi
Date : March 29 2020, 07:55 AM
will help you Simply replace the previous stream instance with null.
This will require a code similar to the following somewhere:
code :
setState(() {
  _messageStream = null;
});
Getting a Stream<List<Object>> from a Stream<Event> from firebase real time database Flutter

Getting a Stream<List<Object>> from a Stream<Event> from firebase real time database Flutter


By : user3717484
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I'm very new to flutter Streams/Bloc/Provider and I'm following a tutorial to understand it. In the tutorial dough they use Firestore so they get a Stream like this: , Use StreamTransformer
code :
Stream<UserAlert> alerts() {
  handleData(Event event, EventSink<UserAlert> sink) =>
      sink.add(UserAlert.fromSnapshot(event.snapshot.value));

  final transformer =
      StreamTransformer<Event, UserAlert>.fromHandlers(handleData: handleData);

  return _databaseReference.onValue.transform(transformer);
}
Related Posts Related Posts :
  • Apply filter to t-foreach
  • Lotus Notes convert formula to agent
  • Problem with configuration of odoo for working with pycharm
  • Unexpected number of arguments when calling EM_JS function
  • What does the function state_fidelity() do in Qiskit?
  • Azure function with IoT Hub trigger get send device
  • Cluster similar words using word2vec
  • Add elements into an array then find distinct,
  • Angular8 - error TS2304: Cannot find name
  • Manually polling streams in future implementation
  • How do you perform receipt validation for Android on Xamarin Forms
  • What is the rule behind instruction count in Intel PIN?
  • How to draw some text when click a button in wxWidgets?
  • Restrict entity types in Spacy NER
  • How to animate CN1 Slider progress on load
  • Issue with bwa mem process not running on all output files from previous process
  • Is (0*1*)* equal to (0 | 1)*?
  • How do I configure phpMyAdmin to start with a blank sql query from the SQL tab?
  • "Objects are not valid as a React child" Redux error when conditionally connecting a component?
  • Displacy results are not showing
  • Strapi / Graphql. What am i doing wrong?
  • How to add Search bar for django template?
  • lookup in presto using single column against a range in lookup table
  • How can you stop videos being stolen on website?
  • Can't code substitution happen in Hybrid Flow?
  • Removed widget remains on parent
  • setup saga middleware with redux-starter-kit's configureStore()
  • How to get cookies from response of scrapy splash
  • Unable to compile node-runtime
  • SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause'
  • How to extract only the number from a variable
  • disable linter in DAML studio
  • RxJS: How to set exhaustMap concurrent?
  • How to remove perforce (p4) on Ubuntu
  • How do they know mean and std, the input value of transforms.Normalize
  • Why this type is not an Interface?
  • SugarCRM Rest API set_relationship between Contacts and Documents
  • Jira dashboard organization
  • Web worker importScripts fails to place script variables in global scope
  • Always errors - The "path" argument must be one of type string, Buffer, or URL. Received type undefined
  • How to create an observable of a stream of infinite items
  • Not efficiently to use multi-Core CPU for training Doc2vec with gensim
  • webGL gl_Position value saving outside shaders
  • Is it okay for a resolver to have side effects besides resolving the type?
  • Move 32bit register into a 8 bit register
  • Is there a way to update, not overwrite, worker_env for a Dask YarnCluster within a script?
  • Lotus Notes Deployment
  • How Do I Add Active Directory To APIM Using Terraform?
  • How to get the old parameter values in Blazor OnParameterSet?
  • How to debug "ERROR: Could not reach the worker node."?
  • How chain indefinite amount of flatMap operators in Reactor?
  • extract dates and times from string in Redshift
  • How do I make a column of 3 cards match in height in bootstrapVue?
  • how to replace missing values from another column in PySpark?
  • only read last line of text file (C++ Builder)
  • Snakemake --forceall --dag results in mysterius Error: <stdin>: syntax error in line 1 near 'File' from Graphvis
  • How Can I Remove Demo Products From APIM Created With Terraform?
  • How to avoid cloning a big integer in rust
  • Break a row of words into word groups in Hive
  • How can I add a path variable to existing files in an Installshield project converted from MSI
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org