Giter VIP home page Giter VIP logo

Comments (9)

yoav-steinberg avatar yoav-steinberg commented on May 9, 2024 2

This might even tie into the "operational style sheets" discussion, where you can customize client initialization based on rules which aren't directly related to your biz-logic but rather to ops issues.

from wing.

eladb avatar eladb commented on May 9, 2024 1

Good call. Let's start with disallowing arguments for ~init() for now and see how it plays out.

(My suspicion is that the inflight client should have all the info it needs from preflight but i may be wrong)

@3p3r add to spec?

from wing.

3p3r avatar 3p3r commented on May 9, 2024

Sounds good. This is an acceptable trade-off I think. The finalizer has the same issue. I'll enforce a compile error for these two methods.

from wing.

staycoolcall911 avatar staycoolcall911 commented on May 9, 2024

Related to #493

from wing.

github-actions avatar github-actions commented on May 9, 2024

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

from wing.

ekeren avatar ekeren commented on May 9, 2024

@yoav-steinberg , I think that the TLDR here is the inflight init is a no param function.

from wing.

Chriscbr avatar Chriscbr commented on May 9, 2024

I wonder how Wing should handle the case of performing async logic in inflight constructors, given our model that inflight is async by default. For example, in the following code

resource MyResource {
  b: cloud.Bucket;
  init(b: cloud.Bucket) {
    this.b = b;
  }
  inflight init() {
    this.b.put("data.json", "{}");
  }
  inflight do_stuff(
    let data = this.b.get("data.json");
    // do stuff
  ) 
}

Maybe the inflight client could look something like

class MyResourceClient {
  init({ b }) {
    this.$init_promises = [];
    this.b = b;
    $init_promises.push(this.b.put("data.json", "{}"));
  }
  async do_stuff() {
    await Promise.all(this.$init_promises);
    const data = (await this.b.get("data.json"));
    // do stuff
  }
}

Alternatively we could inherit the constraint that constructors are sync from the JS world, and give a compiler error (tell the user that this.b.put(...) needs to be prefixed with defer.

from wing.

ekeren avatar ekeren commented on May 9, 2024

@staycoolcall911 , moved this to P1 and Full TaskList

from wing.

monadabot avatar monadabot commented on May 9, 2024

Congrats! 🚀 This was released in Wing 0.10.3.

from wing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.