LaravelPackages.net
Acme Inc.
Toggle sidebar
bfg/puller-alpine

A description for puller-alpine.

14
0
1.0.0
About bfg/puller-alpine

bfg/puller-alpine is a Laravel package for a description for puller-alpine.. It currently has 0 GitHub stars and 14 downloads on Packagist (latest version 1.0.0). Install it with composer require bfg/puller-alpine. Discover more Laravel packages by bfg or browse all Laravel packages to compare alternatives.

Last updated

puller-alpine

Software License Total Downloads

Install

composer require bfg/puller-alpine

Navigate the link to read the documentation in the https://github.com/bfg-s/puller.

Usage

Make sure that in your public/vendor folder published puller-alpine/puller-alpine.js. He had to appear immediately after installing the package, as it broads publications in the laravel-assets group. If this did not happen and you did not appear there, publish it manually:

php artisan vendor:publish --tag=puller-alpine-assets

Connect the script in your document after Alpine initialization:

<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
<script src="{{ asset('vendor/puller-alpine/puller-alpine.js') }}"></script>

Explain logic

All events and their values are stored in the Alpine store. If the store is passivated, then the first call will create a new one if you want to use default states, use assistants for blade or create shops manually.

Blade shorts

<script>
    document.addEventListener('alpine:init', () => {
        Alpine.store('dark_mode', {
            status: true,

            toggle() { // <-- details
                this.status = !this.status;
            }
        })
    })
</script>

Details come to the function, or if this property will be assigned to it.

With Alpine blade directive:

@alpineStore('test', ['state' => true])
@alpineStore([
    'chat' => ['list' => []],
    'online' => ['count' => 0],
])

Generated:

<script type='text/javascript'>document.addEventListener('alpine:init', function () {Alpine.store("test", {"state":true});})</script>
<script type='text/javascript'>document.addEventListener('alpine:init', function () {Alpine.store("chat", {"list":[]});Alpine.store("online", {"count":0});})</script>

Built-in magic

For send Messages

$message('event-name', {my: 'data'})

Built-in stores

$errors

Store with last error list

$error_message

Store with last error message

$status

Store with last puller status code ( 0 - is normal)

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Star History Chart