makenai / robotnik

Drag and drop robotics educational library starring Johnny Five and Blockly (crowd goes wild)
52 stars 13 forks source link

Electron and chrome #27

Closed makenai closed 9 years ago

makenai commented 9 years ago

Hey @BrianGenisio,

Would you mind taking a look at this and seeing if there is more of an angular-friendly way of doing this here?

Specifically, check what I did in the workshop model, and in the workshop component.

There seems to be some nice magic in the original code that used $resource, so that the promise resolved and it just worked like magic. I tried returning a { $promise, $resolved } object, but that didn't work either, so I'm just resolving the promise myself and setting this.workshops that way.

See https://github.com/makenai/robotnik/commit/1bef3110fbf9175b3ad6b6b4e45663e6c3d93e6d#diff-99154f9771711aa6530a77c7f6d8454aR8

and

https://github.com/makenai/robotnik/commit/1bef3110fbf9175b3ad6b6b4e45663e6c3d93e6d#diff-3ebe93536ee604cc74e42dbe24805437R4.

I'm not sure if I'm doing a bad thing by trying to imitate the resource-like models or not.

EDIT: I tried babelify, but ran into some other problems. Went back to es6ify.

BrianGenisio commented 9 years ago

This all looks reasonable. I don't see a problem with emulating the $resource interface. It is a pretty intuitive UI. I like it.

The only "more angular" way of doing things would be to move the Workshops.query() and Workspaces.load() into the router's resolve step. Then the components would get (lowercase) workshops, workshop and workspace instances handed to them.

I can do that in a different PR since it is a bit wonky to do so in the current architecture. As soon as we are able, I want to upgrade from ui-router to the 2.0 router (which is being back-ported to Angular 1.x). But they don't support routing to a component (directive in Angular 1.x) yet, so I'm doing this kind of non-standard router template string thing.

That is all a long way of saying: "what you have is fine, but I'd like to move the data resolution to the router after you merge"

makenai commented 9 years ago

Cool - thanks for the feedback!

I'll merge back in tonight. I spent a good bit of time trying to get code running through Electron. I've settled on a combination of childProcess, IPC and VM, not too dissimilar to what we had before.

After that, I've started working on some code to process the workshops file and turn the component list into code and figure out what to do with the blocks list.

makenai commented 9 years ago

@BrianGenisio Merged to master! Feel free to angularify anything you see fit.