angel_poll 1.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 63

poll

Pub build status

package:angel_client support for "realtime" interactions with Angel via long polling.

Angel supports WebSockets on the server and client, which makes it very straightforward to implement realtime collections. However, not every user's browser supports WebSockets. In such a case, applications might gracefully degrade to long-polling the server for changes.

A PollingService wraps a client-side Service (typically a REST-based one), and calls its index method at a regular interval. After indexing, the PollingService performs a diff and identifies whether items have been created, modified, or removed. The updates are sent out through onCreated, onModified, etc., effectively managing a real-time collection of data.

A common use-case would be passing this service to ServiceList, a class that manages the state of a collection managed in real-time.

import 'package:angel_client/io.dart';
import 'package:angel_poll/angel_poll.dart';

main() {
  var app = new Rest('http://localhost:3000');

  var todos = new ServiceList(
    new PollingService(
      // Typically, you'll pass a REST-based service instance here.
      app.service('api/todos'),

      // `index` called every 5 seconds
      const Duration(seconds: 5),
    ),
  );

  todos.onChange.listen((_) {
    // Something happened here.
    // Maybe an item was created, modified, etc.
  });
}

1.0.0

  • Created package + tests

example/main.dart

import 'package:angel_client/io.dart';
import 'package:angel_poll/angel_poll.dart';

main() {
  var app = new Rest('http://localhost:3000');

  var todos = new ServiceList(
    new PollingService(
      // Typically, you'll pass a REST-based service instance here.
      app.service('api/todos'),

      // `index` called every 5 seconds
      const Duration(seconds: 5),
    ),
  );

  todos.onChange.listen((_) {
    // Something happened here.
    // Maybe an item was created, modified, etc.
  });
}

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_poll: "^1.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angel_poll/angel_poll.dart';
        
Version Uploaded Documentation Archive
1.0.0 Dec 21, 2017 Go to the documentation of angel_poll 1.0.0 Download angel_poll 1.0.0 archive

Analysis

We analyzed this package on Apr 9, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.46.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
26 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
63
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_poll/angel_poll.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0
angel_client ^1.0.0 1.2.0+1
async >=1.10.0 <3.0.0 2.0.6
collection ^1.0.0 1.14.9
Transitive dependencies
angel_http_exception 1.0.0
charcode 1.1.1
http 0.11.3+16
http_parser 3.1.1
json_god 2.0.0-beta+1
merge_map 1.0.0
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
angel_test ^1.1.0
test ^0.12.0