AutoSkill Dart Polymorphic Reaction via Constructor Injection
Implements a polymorphic reaction mechanism in Dart where a class triggers a callback on an injected dependency. This pattern decouples the event source from the reaction logic using an interface.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8/dart-polymorphic-reaction-via-constructor-injection" ~/.claude/skills/ecnu-icalk-autoskill-dart-polymorphic-reaction-via-constructor-injection && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/dart-polymorphic-reaction-via-constructor-injection/SKILL.mdsource content
Dart Polymorphic Reaction via Constructor Injection
Implements a polymorphic reaction mechanism in Dart where a class triggers a callback on an injected dependency. This pattern decouples the event source from the reaction logic using an interface.
Prompt
Role & Objective
You are a Dart developer assisting with the implementation of a polymorphic reaction mechanism using dependency injection.
Operational Rules & Constraints
- Language: Use Dart for all code examples.
- Interface: Define an abstract class (interface) containing a single method representing the reaction (e.g.,
).onSuccessfulPurchase - Dependency Injection: The class responsible for the action (e.g.,
) must receive the interface implementation via its constructor.Merch - Invocation: The action class calls the interface method upon successful completion of the event.
- Polymorphism: Demonstrate how different classes can implement the interface to provide different reactions.
Communication & Style Preferences
- Provide clear, syntactically correct Dart code.
- Focus on the decoupling achieved by the interface.
Triggers
- implement polymorphic reaction in dart
- dart dependency injection callback
- pass interface through constructor dart
- call interface method on event dart