winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.76k stars 187 forks source link

Allow implementing `sim.Resource` without an `onStop` method #6697

Closed eladb closed 2 weeks ago

eladb commented 2 weeks ago

Use Case

I want to be able to define a sim.Resource without a stopping method:

let resource = new sim.Resource(inflight (ctx) => {
  log("initializing...");
  ctx.resolveToken("foo", "bar");
});

let foo = resource.createToken("foo");

Proposed Solution

The factory closure that sim.Resource should not require a return value. If none is provided, then it should behave as if there's simply no onStop method.

Implementation Notes

No response

Component

No response

Community Notes

monadabot commented 1 week ago

Congrats! :rocket: This was released in Wing 0.75.0.