d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Kinetic: A view-composer package for Intertia.js

Kinetic adds view-composer-like features to the Inertia.js Laravel adapter. Like Laravel view composers, Kinetic can bind data each time a component is rendered from a single location.

Within a service provider, you can call the composer() method to define Inertia composers:

1// In a service provider

2public function boot()

3{

4 // Class-based composer..

5 Inertia::composer('User/Profile', UserComposer::class);

6}

7 

8// Composer class

9class UserComposer

10{

11 public function compose(ResponseFactory $inertia)

12 {

13 $inertia->with('list', [

14 'foo' => 'bar',

15 'baz' => 'buzz'

16 ]);

17 }

18}

The composer() method supports closure-based composers as well:

1Inertia::composer('User/Profile', function (ResponseFactory $inertia) {

2 $inertia->with([

3 'post' => [

4 'subject' => 'Hello World!',

5 'description' => 'This is a description.'

6 ]

7 ]);

8});

With composers defined in a service provider, your props will include the composing data when you call render():

1// Includes bound data from `Inertia::composer('User/Profile')`

2Inertia::render('User/Profile');

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this