joris hermans edited this page May 8, 2015 · 17 revisions

Introduction

Dart Force is a Realtime web framework for Dart. We will make it easy for you to create realtime applications with it in Dart, like a chat, interactive dashboard, multiplayer games, ...

How does it work?

Serverside

First of all you need a server to handle incoming messages and dispatch or handle this messages correctly.

import "package:force/force_serverside.dart";

ForceServer fs = new ForceServer();

main() {
  fs.server.use("/", (req, model) => "dartforcetodo");

  fs.start().then((_) {
    fs.on("add", (vme, sender) {
      fs.send("update", vme.json);
    });
  });
}
Clientside

The client can listen to messages:

ForceClient fc;
void main() {
  fc = new ForceClient();
  fc.connect();
  
  fc.onConnected.listen((e) {
    fc.on("update", (fme, sender) {
      querySelector("#list").appendHtml("<div>${fme.json["todo"]}</div>");
    });
  });
}

You can also send messages:

InputElement input = querySelector("#input");
var data = {"todo": input.value};
fc.send("add", data);

It is a little bit inspired by socket.io for the communication flow.

Quick starter guide

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.