Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

worker injection #12

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up worker creation
runspired committed Apr 7, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 80a5dc91f1b04368d4885d1e29368cf9e6f0814d
38 changes: 16 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,56 +8,50 @@ Skyrocket
Skyrocket enables you to build multi-threaded applications, helping you create apps
that consistently function at 60fps even in the most advanced use cases in hostile environments.

- [Overview](./OVERVIEW.md)
- [Terminology Guide](./Terminology.md)


## Installation

`ember install skyrocket-engine`


## Usage


### Scaffolding A Worker
### Scaffold A Worker

```cli
ember g worker data-store
ember g worker <worker-name>
```

Produces the following:
```cli
/app/workers/data-store/
interface.js
/app/workers/<worker-name>/
contract.js
worker.js
```

When building or serving your ember application, this worker will be built as
as stand alone file located at `/assets/workers/data-store.js`.
When building or serving your ember application, `<worker-name>/worker.js` will be built as
as stand alone file located at `/assets/workers/<worker-name>.js`, while
`<worker-name>/contract.js` will be loaded into your app.

### Imports

Currently any module from your `app`, from an `addon`, and `Ember` can be imported.
Your worker can take full advantage of `es6` imports.

### Restrictions

Importing from `bower_components` and non-addons is not currently possible, nor is
the Browser environment currently shimmed. In the near future, you will be able
to provide your worker a browser shim as well.


Workers are workers, if a module does something that uses a browser API
that's not available in a worker, it will error. In the near future,
you will be able to import environment stubs to provide your worker needed
browser shims as well.


## Creating Your First Worker

### The interface
### The Contract

The interface is a "model" of your Worker's exposed API. It represents the
The contract is a "model" of your Worker's exposed API. It represents the
asynchronous methods, events, and properties (called snapshots) which will be available
to your app.

```js
import { Interface, Primitives:p } from 'skyrocket';
import { Contract, Primitives:p } from 'skyrocket';

export default Interface.extend({
foo: p.snapshot(),
6 changes: 6 additions & 0 deletions blueprints/worker/files/__root__/workers/__name__/contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Contract } from 'skyrocket';
import { method, event, snapshot, array, object, task } from 'skyrocket/primitives';

export default Contract.extend({

});

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
var treeForWorkers = require('./lib/tree-for-workers');

module.exports = {
name: 'skyrocket',
name: 'skyrocket-engine',

isDevelopingAddon: function() {
return true;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "skyrocket",
"name": "skyrocket-engine",
"version": "0.0.0",
"description": "Ambitious applications aren't single threaded",
"directories": {
14 changes: 3 additions & 11 deletions tests/dummy/app/workers/data-store/contract.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { Contract, Primitives } from 'skyrocket';
import { Contract } from 'skyrocket';
import { method, event, snapshot, array, object, task } from 'skyrocket/primitives';

const {
method,
event,
snapshot,
array,
object,
task
} = Primitives;

export default Contract.create({
export default Contract.extend({
fetch: method(),
message: event(),
forceLogout: event({ outbound: false }),