Skip to content

Commit ebd0a5f

Browse files
authored
Merge pull request #102 from thefrontside/update-effection
2 parents e61e003 + 6c7387b commit ebd0a5f

File tree

12 files changed

+163
-291
lines changed

12 files changed

+163
-291
lines changed

.changes/effection-preview-6.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@simulacrum/client": minor
3+
"@simulacrum/server": minor
4+
"@simulacrum/ui": minor
5+
---
6+
upgrade to effection@2.0.0-beta.6

package-lock.json

Lines changed: 131 additions & 265 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/auth0/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@
2929
},
3030
"homepage": "https://github.com/thefrontside/simulacrum#readme",
3131
"dependencies": {
32-
"@effection/process": "^2.0.0-beta.3",
32+
"@effection/process": "^2.0.0-beta.6",
3333
"@simulacrum/server": "0.2.0",
3434
"@types/faker": "^5.1.7",
3535
"assert-ts": "^0.3.2",
3636
"base64-url": "^2.3.3",
3737
"cookie-session": "^1.4.0",
38-
"effection": "^2.0.0-beta.3",
38+
"effection": "^2.0.0-beta.6",
3939
"html-entities": "^2.3.2",
4040
"jsesc": "^3.0.2",
4141
"jsonwebtoken": "^8.5.1"
4242
},
4343
"devDependencies": {
44-
"@effection/atom": "^2.0.0-beta.3",
45-
"@effection/mocha": "^2.0.0-beta.3",
44+
"@effection/atom": "^2.0.0-beta.6",
45+
"@effection/mocha": "^2.0.0-beta.6",
4646
"@frontside/eslint-config": "^2.0.0",
4747
"@frontside/tsconfig": "^1.2.0",
4848
"@frontside/typescript": "^1.1.1",

packages/auth0/test/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function createTestServer(options: ServerOptions): Resource<Client> {
1010
let server: Server = yield createSimulationServer(options);
1111
let { port } = server.address;
1212
let client = createClient(`http://localhost:${port}`);
13-
scope.spawn(function*() {
13+
scope.run(function*() {
1414
try {
1515
yield;
1616
} finally {

packages/auth0/watch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ main(function* (scope: Task) {
77

88
let watcher = watch(['../server/src/**/*.ts', './src/**/*.ts'], { ignoreInitial: true, ignored: 'dist' });
99
try {
10-
let process: Task = scope.spawn(buildAndRun);
10+
let process: Task = scope.run(buildAndRun);
1111

1212
yield on(watcher, 'all').forEach(() => {
1313
process.halt();
14-
process = scope.spawn(function*() {
14+
process = scope.run(function*() {
1515
yield sleep(10);
1616
console.log('rebuilding.....');
1717
yield buildAndRun;

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "echo client is used to test server"
1313
},
1414
"dependencies": {
15-
"effection": "^2.0.0-beta.3",
15+
"effection": "^2.0.0-beta.6",
1616
"graphql-ws": "^4.2.3",
1717
"isomorphic-ws": "^4.0.1"
1818
},

packages/client/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ export function createClient(serverURL: string): Client {
7272
return {
7373
run(scope: Task) {
7474
let { send, close, stream } = createChannel<Result<T>>();
75-
let { future, resolve } = createFuture<void>();
76-
scope.spawn(function*() {
75+
let { future, produce } = createFuture<void>();
76+
scope.run(function*() {
7777
let unsubscribe = ws.subscribe<Result<T>>(payload, {
7878
next: send,
79-
complete: () => resolve({ state: "completed", value: undefined }),
79+
complete: () => produce({ state: "completed", value: undefined }),
8080
error: () => null
8181
});
8282
try {
@@ -92,7 +92,7 @@ export function createClient(serverURL: string): Client {
9292
}
9393

9494
async function query<T>(field: string, payload: SubscribePayload): Promise<T> {
95-
return scope.spawn(function*(child) {
95+
return scope.run(function*(child) {
9696
yield sleep(10);
9797
let subscription = subscribe<Record<string, T>>(payload).run(child);
9898
let result: Result<Record<string, T>> = yield subscription.expect();
@@ -135,15 +135,15 @@ mutation DestroySimulation($id: String!) {
135135
variables: { id }
136136
}),
137137
state<T = unknown>() {
138-
let child = scope.spawn();
138+
let child = scope.run();
139139

140140
let subscription = subscribe<T>({
141141
query: `subscription { state }`
142142
}).run(child);
143143

144144
let iterator = {
145145
next() {
146-
return child.spawn(function*() {
146+
return child.run(function*() {
147147
let next: IteratorResult<Result<{ state: T }>> = yield subscription.next();
148148
if (next.done) {
149149
return { done: true };

packages/server/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
},
2828
"homepage": "https://github.com/thefrontside/simulacrum#readme",
2929
"dependencies": {
30-
"@effection/atom": "^2.0.0-beta.3",
31-
"@effection/process": "^2.0.0-beta.3",
30+
"@effection/atom": "^2.0.0-beta.6",
31+
"@effection/process": "^2.0.0-beta.6",
3232
"@simulacrum/ui": "0.0.2",
3333
"@types/faker": "^5.1.7",
3434
"assert-ts": "^0.3.2",
3535
"cors": "^2.8.5",
36-
"effection": "^2.0.0-beta.3",
36+
"effection": "^2.0.0-beta.6",
3737
"express": "^4.17.1",
3838
"express-graphql": "^0.12.0",
3939
"faker": "^5.5.0",
@@ -45,7 +45,7 @@
4545
"ws": "^7.4.4"
4646
},
4747
"devDependencies": {
48-
"@effection/mocha": "^2.0.0-beta.3",
48+
"@effection/mocha": "^2.0.0-beta.6",
4949
"@frontside/eslint-config": "^2.0.0",
5050
"@frontside/tsconfig": "^1.2.0",
5151
"@frontside/typescript": "^1.1.1",

packages/server/src/effect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function map<A>(slice: Slice<Record<string, A>>, effect: Effect<A>): Oper
2121
// see comment above
2222
if (value) {
2323
if (!effects.has(key)) {
24-
effects.set(key, scope.spawn(effect(slice.slice(key))));
24+
effects.set(key, scope.run(effect(slice.slice(key))));
2525
}
2626
keep.add(key);
2727
}

packages/server/src/schema/resolvers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const createSimulation: Resolver<CreateSimulationParameters, SimulationSt
2727
let simulation = atom.slice("simulations").slice(id);
2828
simulation.set({ id, status: 'new', simulator, options, services: [], scenarios: {}, store: {} });
2929

30-
return scope.spawn(simulation.filter(({ status }) => status !== 'new').expect());
30+
return scope.run(simulation.filter(({ status }) => status !== 'new').expect());
3131
}
3232
};
3333

@@ -59,7 +59,7 @@ export const given: Resolver<GivenParameters, ScenarioState> = {
5959
let scenario = simulation.slice('scenarios').slice(id);
6060
scenario.set({ id, status: 'new', name: scenarioName, params });
6161

62-
return scope.spawn(scenario.filter(({ status }) => status !== 'new').expect());
62+
return scope.run(scenario.filter(({ status }) => status !== 'new').expect());
6363
}
6464
};
6565

@@ -70,7 +70,7 @@ interface StateParameters {
7070
export const state: Subscriber<StateParameters, ServerState> = {
7171
subscribe(_args, { scope, atom }) {
7272
let queue = createQueue<ServerState>();
73-
scope.spawn(atom.forEach(queue.push));
73+
scope.run(atom.forEach(queue.push));
7474
return {
7575
[Symbol.asyncIterator]: () => ({
7676
async next(): Promise<IteratorResult<ServerState>> {

packages/server/src/simulation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function simulation(simulators: Record<string, Simulator>): Effect<Simula
3131
app.use(function(req, res, next) {
3232
assert(middlewareHandlerIsOperation(handler), 'invalid middleware function');
3333

34-
scope.spawn(handler(req, res))
34+
scope.run(handler(req, res))
3535
.then(next)
3636
.catch(next);
3737
});
@@ -41,7 +41,7 @@ export function simulation(simulators: Record<string, Simulator>): Effect<Simula
4141

4242
for (let handler of service.app.handlers) {
4343
app[handler.method](handler.path, (request, response) => {
44-
scope.spawn(function*() {
44+
scope.run(function*() {
4545
try {
4646
yield handler.handler(request, response);
4747
} catch(err) {

packages/server/src/websocket-transport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export function createWebSocket(ws: WS): Resource<WebSocket> {
7979
close: (code, reason) => ws.close(code, reason),
8080
onMessage(cb) {
8181
// spawn a task to dispatch each message asynchronously.
82-
scope.spawn(on<WS.MessageEvent>(ws, 'message').forEach(message => {
83-
scope.spawn(cb(message.data.toString()));
82+
scope.run(on<WS.MessageEvent>(ws, 'message').forEach(message => {
83+
scope.run(cb(message.data.toString()));
8484
}));
8585
}
8686
};

0 commit comments

Comments
 (0)