Tick Tack Toe with Horizon and RethinkDB

@MichalZalecki

Collection API

  • Collection.fetch
  • Collection.subscribe
  • Collection.watch
  • Collection.above
  • Collection.below
  • Collection.find
  • Collection.findAll
  • Collection.limit
  • Collection.order
  • Collection.remove
  • Collection.removeAll
  • Collection.insert
  • Collection.replace
  • Collection.store
  • Collection.update
  • Collection.upsert
  • Aggregates and models

Embedding Horizon

const app = express();
const httpServer = https.createServer(sslOpts, app).listen(PORT);

const horizonServer = horizon(httpServer, hzOpts);
horizonServer._reql_conn._ready_promise.then((reql_conn) => {
  const r = horizon.r;
  const connection = reql_conn.connection();

  r.table("games").changes().run(connection).then(...);
});

Authentication

horizonServer.add_auth_provider(
  horizon.auth.twitter, { id, secret, path }
);

horizonServer.add_auth_provider(
  horizon.auth.github, { id, secret, path }
);
function login(provider) {
  hz.authEndpoint(provider).subscribe((endpoint) => {
    window.location.replace(endpoint);
  });
}

Let's <code />!

Made with Slides.com