freezed icon indicating copy to clipboard operation
freezed copied to clipboard

Add `@Body`/`@Initializer` annotations

Open dan-leech opened this issue 4 years ago • 2 comments

I like new @Assert decorator very much. But I also need @Event decorator. :)

I think it would be very good to have custom decorators. Might they exist? I expect something like JsonConverter but for a constructor initialiser with overriding init method.

In generated code it would looks like this:

class Example {
  Example(Params params): assert(someAssertion  == true) {
    @Initialiser().init?.call() // or better: call(params)
  }
}

dan-leech avatar Jan 18 '21 08:01 dan-leech

What would an @Event do?

rrousselGit avatar Jan 19 '21 05:01 rrousselGit

For events I need to send custom events like "model has been created" to a broadcaster, but this is custom code too.

What would an @Event do?

It's just the same idea as for @Initialiser witch can be customised as developer want. The idea is running any code in a class constructor body.

dan-leech avatar Jan 20 '21 11:01 dan-leech