Open jose-carmona opened 4 years ago
Support for Dependency Injection based on Injector.
Example
Provider:
class AppModule(Module): @provider @singleton def provide_str(self) -> str: return 'TEST INJECTED' @provider @singleton def provide_int(self) -> int: return 42
Init:
app = Flask(__name__) module = AppModule() injector = Injector([module]) assist = Assistant(app, project_id="test-project-id", injector=injector)
Dependency Injection in action decorator:
@assist.context("context_1") @assist.action("intent_with_context_injects_params") @inject def intent_with_context_injects_params(speech: str, p1, p2, i: int): return ask("context_1:" +speech + ":" + p1 + ":" + p2 + ":" +str(i))
Support for Dependency Injection based on Injector.
Example
Provider:
Init:
Dependency Injection in action decorator: