Printer Logo

Printer

Please note the project has upgraded to Next App Directories in v2.x.x

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 pages/example --no-state
λ ... Injects only actions
λ printer inject example pages/example --no-action
λ ... Injects only state
λ Short hand usage
λ printer inject example pages/example -s
λ printer inject example pages/example -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 example pages/example
λ ...

This will update the example page to the following.