Skip to content

📦 An easy way to work with the shared data delivered by "coderello/laravel-shared-data".

License

Notifications You must be signed in to change notification settings

coderello/js-shared-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Shared Data

This package provides a front-end solution for the coderello/laravel-shared-data package.

Install

yarn add js-shared-data

Usage

Let's imagine that we shared such data from the backend using coderello/laravel-shared-data:

share([
    'user' => [
        'full_name' => 'Ilya Sakovich',
        'username' => 'hivokas',
        'email' => '[email protected]',
    ],
    'balance' => 120,
]);

On the front-end side we can access this data using shared() helper.

import shared from 'js-shared-data';

// retrieve the user object
const user = shared('user');

// retrieve the username from the user object
const username = shared('user.username');

// retrieve the balance
const balance = shared('balance');

// specify the default value which will be used if value for specified path doesn't exist
const status = shared('status', 'Working...');

About

📦 An easy way to work with the shared data delivered by "coderello/laravel-shared-data".

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published