Printer Logo

Printer

Injecting Slices into Components

Injections are designed to automatically map state and actions to a component with a simple command. Injections map printer decorators in slices to Components with a command. Therefore, before being able to benefit from Printer injections, you will need to setup all the decorators in your Slice first.

λ Usage
λ printer inject [slice name] [component or page path]
λ This command injects the example slice into the component
λ printer inject example pages/example
λ ...

You can optionally choose not to inject state or actions. Add the --no-action or --no-state flags to choose not to add state or actions.

λ Example Usage
λ printer inject example app/example/page --no-state
λ ... Injects only actions
λ printer inject example app/example/page --no-action
λ ... Injects only state
λ Short hand usage
λ printer inject example app/example/page -s
λ printer inject example app/example/page -a

In order to leverage Printer injections. Let's take a look at the same file from the Slice page. There are two different types of Printer decorations. The first is a simple @printer::inject which injects the state or action implicitly. The second is a Printer decoration with types mapped to the state.

With the example slice properly setup for Printer injections. You can now run the injection command.

λ printer inject counter app/example/page
λ ...

This will update the example page to the following.