Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-shared-data

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-shared-data

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

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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' => 'me@hivokas.com',
    ],
    '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...');

Customization

import { sharedData } from 'js-shared-data';

// specify the default value globally
sharedData.setDefaultValue(null);

// specify the namespace which contains an object with all shared data
sharedData.setNamespace('App');

// specify the source
sharedData.setSource(window);

Keywords

FAQs

Package last updated on 31 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc