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

@ryangjchandler/fern

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ryangjchandler/fern

Persisted global stores for Alpine 3.x.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

✨ Help support the maintenance of this package by sponsoring me.

Fern

Persisted global stores for Alpine 3.x.

Installation

Since Fern directly extends the global Alpine object, the recommended installation methods are NPM or a module <script> tag.

NPM

Install Fern by running the following command:

npm install @ryangjchandler/fern

Inside of your main script, add the following code:

import Alpine from 'alpinejs'
import Fern from '@ryangjchandler/fern'

Alpine.plugin(Fern)

Alpine.start()

<script type="module">

Add the following <script> to the <head> of your document before including Alpine:

<script type="module">
    import Fern from 'https://cdn.jsdelivr.net/npm/@ryangjchandler/alpine-tooltip@0.x.x/dist/module.esm.js'

    document.addEventListener('alpine:initializing', () => {
        window.Alpine.plugin(Fern)
    })
</script>

Usage

Fern adds a new persistedStore method to the global Alpine object. The method's definition and usage is identical to Alpine.store():

Alpine.plugin(Fern)

Alpine.persistedStore('counter', 0)

Alpine.start()

Creating a persistedStore will register a normal store with Alpine and keep track of all changes, pushing them back to localStorage when updated.

<div x-data>
    <p x-text="$store.counter"></p>
    <button x-on:click="$store.counter++">Increment</button>
</div>

If you're using the <script type="module"> installation method, be sure to make your persistedStore calls after registering Fern.

    document.addEventListener('alpine:initializing', () => {
        window.Alpine.plugin(Fern)

        window.Alpine.persistedStore('counter', 0)
    })

Versioning

This projects follow the Semantic Versioning guidelines.

License

Copyright (c) 2021 Ryan Chandler and contributors

Licensed under the MIT license, see LICENSE.md for details.

FAQs

Package last updated on 16 Jun 2021

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