These are chat archives for orbitjs/orbit.js

7th
Jan 2016
Oliver Searle-Barnes
@opsb
Jan 07 2016 00:38
@dgeb I want to expose ember-orbit’s Store automatically when the ember-orbit addon is present. Unfortunately, ember addons include ember-data by default so we can’t expose it as service:store. It seems like the pragmatic way forwards for now is to expose it as service:orbitStore. Any thoughts?
Just not sure how we could force ember-orbit to register it’s Store before ember-data
Oliver Searle-Barnes
@opsb
Jan 07 2016 01:18
been giving a little thought to how we might configure ember-orbit
// where topology is a preset for the co-ordinator
ENV.emberOrbit = {
  topology: {
    offline: 'localStorage',
    remote: 'rethinkdb'
  },
  sources: {
    localStorage: { namespace: 'appName' },
    rethinkdb: { host: 'https://localhost:7000', username: 'abc', password: '123' },
    jsonApi: { host: 'https://localhost:7000', username: 'abc', password: '123' }
  }
}
there go those grey blocks again...
so I thought we could have a default topology but we could allow topology factories to be registered and then specified (as a preset):
ENV.emberOrbit = {
  topology: {
    preset: ‘optimisticui',
    offline: 'localStorage',
    remote: 'rethinkdb'
  },
  // ...
}
Dan Gebhardt
@dgeb
Jan 07 2016 03:54
@opsb for now, I think we can simply require ember-orbit to be installed instead of ember-data
Oliver Searle-Barnes
@opsb
Jan 07 2016 03:55
the problem is that all ember addons require ember-data to be installed
ah, tell a lie, master doesn’t, ember-cli/ember-cli-shims@bb0b53c
phew
Dan Gebhardt
@dgeb
Jan 07 2016 03:56
:)
Oliver Searle-Barnes
@opsb
Jan 07 2016 03:56
just addons requiring an out of date version
hopefully that shouldn’t be the case for long though
Dan Gebhardt
@dgeb
Jan 07 2016 03:56
right
Oliver Searle-Barnes
@opsb
Jan 07 2016 03:57
what do you think about config?
I’d like to integrate chatty-web with ember-orbit tomorrow
Dan Gebhardt
@dgeb
Jan 07 2016 03:57
I think the sources section is fine
Oliver Searle-Barnes
@opsb
Jan 07 2016 03:58
I suppose I can just wire something up temporarily in chatty-web
Dan Gebhardt
@dgeb
Jan 07 2016 03:58
yeah, I think the topology might be premature
Oliver Searle-Barnes
@opsb
Jan 07 2016 03:58
(it just needs to expose orbitStore:main)
ok
Dan Gebhardt
@dgeb
Jan 07 2016 03:58
the topology is rather high level
let's stick with initializers to start
and then see what best practices emerge
Oliver Searle-Barnes
@opsb
Jan 07 2016 03:59
ok, I wanted to match ember-data’s built in initialisers, but you’re right, we should wait and see
Dan Gebhardt
@dgeb
Jan 07 2016 04:00
yeah, I think we'll get there soon
Oliver Searle-Barnes
@opsb
Jan 07 2016 04:00
yeah, I’m just trying to get a full-stack example up and running
but an initialiser with some custom code is fine for that
Dan Gebhardt
@dgeb
Jan 07 2016 04:01
ok cool
Oliver Searle-Barnes
@opsb
Jan 07 2016 04:24
ok, I’ve removed any traces of ember-data from ember-orbit’s dependencies now
Oliver Searle-Barnes
@opsb
Jan 07 2016 07:00

@dgeb I’ve got a bare bones demo running, https://github.com/opsb/chatty-web/tree/orbit_integration

If you want to try it out you’ll need to manually link https://github.com/opsb/ember-orbit/tree/convert_to_ember_addon and https://github.com/orbitjs/orbit.js/tree/rethink

It’s a very bare bones slack clone at the moment, with just an in-memory store/cache. If you see a text box, just enter something and hit return. (rooms on the left, messages at the bottom).

I’m considering pulling orbit-rethinkdb together as I’ve already done the hard work of implementing mutations and listeners, we just need to pin down how orbitStore.liveQuery and source.liveQuery will work.

Oliver Searle-Barnes
@opsb
Jan 07 2016 20:52

@dgeb thought I'd get the ball rolling with the liveQuery api.

We've discussed the API for the store already, I think we got to:

liveQuery = store.liveQuery()
liveQuery.subscribe(operation => {})

where liveQuery is the results from store.cache.liveQuery.

The question is how liveQueries are distributed to other sources.

LiveQueryable = {
  init(...args) {
    this._super(...args);

    Evented.extend(this);
  }

  liveQuery(query) {
    // not sure if any of the existing Evented methods match 'mapAll' here


    const promisedLiveQueries = Promise.all([
      this._liveQuery(query), 
      ...this.mapAll('liveQuery', query)
    ]);

    return promisedLiveQueries.then(liveQueries => RxJS.Observeable.merge(liveQueries));
  }
}

export default Source.extend({
  init(...args) {
    this._super(...args);
    LiveQueryable.extend(this);
  },

  _liveQuery(query) {
    // setup liveQuery for current source
  }
});

to wire up the sources

sourceA.on('liveQuery', sourceB.liveQuery);
sourceA.on('liveQuery', sourceC.liveQuery);
sourceC.on('liveQuery', sourceD.liveQuery);

new Orbit.TransformConnector(sourceA, sourceB);
new Orbit.TransformConnector(sourceA, sourceC);

note the connectors are uni-directional, all results flow back to the store via the liveQueries (still thinking on the implications of this).

Dan Gebhardt
@dgeb
Jan 07 2016 20:54
@opsb oh hey - exciting news about the chatty demo!
let me review your thoughts on liveQuery
Oliver Searle-Barnes
@opsb
Jan 07 2016 20:55
I've also been given access to rethinkdb's fusion project so I'm reviewing that
Dan Gebhardt
@dgeb
Jan 07 2016 20:55
nice
Oliver Searle-Barnes
@opsb
Jan 07 2016 20:56
I've requested access for you as well, hopefully you'll get it tomorrow
Dan Gebhardt
@dgeb
Jan 07 2016 20:56
thanks :)
if only I had the time to deep dive with all these projects
I'll have to rely on you to point me to the interesting bits at first
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:02
Sure, trying to decide what to do about rethinkdb's integration at the moment. Trying to establish whether or not fusion supports arbitrary queries or not.
Dan Gebhardt
@dgeb
Jan 07 2016 21:03
hmmm that will make quite a difference in how you implement your orbit source
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:03
Yep :)
At the moment I'm on the fence as to which approach is better
They seem to be aiming at the rapid prototype scenario with fusion, with the expectation that you would migrate to a node backend or similar later.
It may even make sense to have sources for both fusion and direct to rethinkdb.
Dan Gebhardt
@dgeb
Jan 07 2016 21:06
that sounds right
given how different they seem to be
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:06
No doubt fusion's scope will grow in time though
Dan Gebhardt
@dgeb
Jan 07 2016 21:06
it doesn't seem like it's a very open API
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:07
Hard to tell at the moment, they do hint at supporting arbitrary queries but it isn't clear from the existing docs
Dan Gebhardt
@dgeb
Jan 07 2016 21:07
I imagine you're going to be keeping the client/server together in lockstep until then
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:07
I've asked the question so hopefully I'll get some clarity over the next day or so
Dan Gebhardt
@dgeb
Jan 07 2016 21:08
:+1:
as for connecting liveQueries - my initial inclination is to not attempt to get too clever at first
oh hey - just got my invite to rethink
thanks :)
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:09
Sure, happy to do some extra leg work to wire things up at this stage
Not sure what the simplest possible API is though
Nice
Perhaps sources don't do any aggregation for now and just return their own results
Dan Gebhardt
@dgeb
Jan 07 2016 21:11
yes, that's my thought
I really want to take a few weeks working with queries / liveQueries in a non-trivial project
to see what patterns emerge
it will be very flexible
but probably feel a bit redundant
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:12
We could plug in a co-ordinator to handle aggregation
Dan Gebhardt
@dgeb
Jan 07 2016 21:13
well, I definitely want a coordinator for transforms
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:13
I think co-ordinators should sit between the Store and the Sources
Dan Gebhardt
@dgeb
Jan 07 2016 21:14
we need to map out the optimistic UI flow (like you started)
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:15
Yeah, I think that would be a good place to start
I think it will be far easier to model using rxjs
Dan Gebhardt
@dgeb
Jan 07 2016 21:17
:)
Oliver Searle-Barnes
@opsb
Jan 07 2016 21:19
Ok, so let's go with a dumb liveQuery API on the sources and I'll have a go at inserting a basic coordinator between the Store and the Sources. Initially it can just aggregate liveQueries an distribute transforms. I think it will be a bit of a big black box but we can extract components from there.
Dan Gebhardt
@dgeb
Jan 07 2016 21:20
ok, sounds like a good start