Skip to content

Commit

Permalink
Merge of #4235
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 21, 2023
2 parents 162d0e8 + 3e8fb78 commit 11b5484
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 10 additions & 2 deletions apps/wing-console/console/app/demo/main.w
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bring cloud;
bring ex;

let secret = new cloud.Secret(name: "my-secret");
// @see https://github.com/winglang/wing/issues/4237 it crashes the Console preview env.
//let secret = new cloud.Secret(name: "my-secret");

let bucket = new cloud.Bucket();
let queue = new cloud.Queue();
Expand Down Expand Up @@ -69,6 +69,14 @@ rateSchedule.onTick(inflight () => {
log("Rate schedule ticked!");
});

new cloud.Service(
onStart: inflight () => {
log("start!");
},
onStop: inflight () => {
log("stop!");
});

let cronSchedule = new cloud.Schedule(cloud.ScheduleProps{
cron: "* * * * ?"
}) as "Cron Schedule";
Expand Down
5 changes: 2 additions & 3 deletions libs/wingsdk/src/target-sim/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class Service extends cloud.Service implements ISimulatorResource {
props.onStart,
"ServiceOnStart"
);
Node.of(onStartFunction).title = "onStart()";
this.onStartHandlerToken = simulatorHandleToken(onStartFunction);

Node.of(this).addConnection({
Expand All @@ -37,6 +38,7 @@ export class Service extends cloud.Service implements ISimulatorResource {
props.onStop,
"ServiceOnStop"
);
Node.of(onStopFunction).title = "onStop()";
this.onStopHandlerToken = simulatorHandleToken(onStopFunction);

Node.of(this).addConnection({
Expand All @@ -46,7 +48,6 @@ export class Service extends cloud.Service implements ISimulatorResource {
});
}
}

private createServiceFunction(
handler: cloud.IServiceOnEventHandler,
id: string
Expand All @@ -69,8 +70,6 @@ export class Service extends cloud.Service implements ISimulatorResource {
{}
);
Node.of(fn).sourceModule = SDK_SOURCE_MODULE;
Node.of(fn).title = "onStart()";

this.node.addDependency(fn);
return fn;
}
Expand Down

0 comments on commit 11b5484

Please sign in to comment.