GregoryConrad / rearch-dart

Re-imagined approach to application design and architecture
https://pub.dev/packages/rearch
MIT License
88 stars 4 forks source link

Macros (Dart/Flutter) #14

Open GregoryConrad opened 10 months ago

GregoryConrad commented 10 months ago

@rearchSideEffect TextEditingController _textEditingController(UseUnstatePlugin use, String? initialText) { final controller = use.memo(() => TextEditingController(text: initialText)); use.effect(() => controller.dispose, [controller]); return controller; }

// Generates an extension: extension UseTextEditingController on UseUnstatePlugin { TextEditingController textEditingController(String? initialText) { return textEditingController(this, initialText); } }



Edit: per https://github.com/GregoryConrad/rearch-dart/issues/95#issuecomment-1925828051, we should just make one macro for any type of capsule (factory, action, async etc). That leads to a cleaner API.
opsb commented 4 months ago

Given macros could potentially be a year away or longer, would it be worth adding the macros using build_runner for now?

GregoryConrad commented 4 months ago

@opsb unfortunately I don’t have the time to go out and learn build_runner right now. Macros in ReArch aren’t going to bring any new features to the table, but rather just be a QoL improvement for boilerplate reduction.