The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::AutoReload - Automatically reload open browser windows when your application changes

VERSION

version 0.001

SYNOPSIS

    use Mojolicious::Lite;
    plugin AutoReload => {};
    get '/' => 'index';
    app->start;

    __DATA__
    @@ layouts/default.html.ep
    %= auto_reload;
    %= content;

    @@ index.html.ep
    % layout 'default';
    Hello world!

DESCRIPTION

This plugin automatically reloades the page when the Mojolicious webapp restarts. This is especially useful when using the Morbo development server, which automatically restarts the webapp when it detects changes. Combined, morbo and Mojolicious::Plugin::AutoReload will automatically display your new content whenever you change your webapp in your editor!

This works by opening a WebSocket connection to a specific Mojolicious route. When the server restarts, the WebSocket is disconnected, which triggers a reload of the page.

HELPERS

auto_reload

The auto_reload template helper inserts the JavaScript to automatically reload the page. This helper only works when the application mode is development, so you can leave this in all the time and have it only appear during local development.

ROUTES

/auto_reload

This plugin adds a /auto_reload WebSocket route to your application.

SEE ALSO

Mojolicious

AUTHOR

Doug Bell <preaction@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Doug Bell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.