NAME

Para::Frame::Reload - Reloads updated modules in the app

SYNOPSIS

  use Para::Frame::Reload;

DESCRIPTION

Updated actions are always reloaded if touched.

For all other modules; Insert the use row in the module, and it will be checkd for updates at the beginning of each request. The use row must be loaded AFTER the definition of any import() method. If Exporter is used, place use Para::Frame::Reload after the use base qw( Exporter) .

call_import()

  Para::Frame::Reload->call_import()
  Para::Frame::Reload->call_import( $pkgname )

The Relod module will intercept calls to import(), regestring the modules and the parameters they are sending. When a registred module is reloaded, the import() will be called from the perspective of each calling module.

This will not be done if the registred module has defined a on_reload() method. In that case, you will have to call this method yourself;

If you can call it without $pkgname, it will be set to the caller package.

The resone for this import() handling is that even if the module is reloaded, the other modules that have imported functions still has a reference to the old version. (If you used Exporter)

This is done by creating an import() function in the module that will call the original import(). This original import is probably the Exporter import() function, loaded by UNIVERSAL.

Subsequent imports are called via special on_reload_...() methods placed in the module namespace;

sub on_reload

If the module has a on_reload() method, it will be called after the modules has been reloaded. This is not a method of Para::Frame::Reload.

You can use this callback for calling the modules_importing_from_us() method, like this:

  sub on_reload
  {
      Para::Frame::Reload->modules_importing_from_us;
  }

modules_importing_from_us()

  Para::Frame::Reload->modules_importing_from_us()
  Para::Frame::Reload->modules_importing_from_us( $pkgname )

If you can call it without $pkgname, it will be set to the caller package.

This will reload all modules that used $pkgname. That reload will take care of the import() calls, making the call_import() method redundant.

This is necessary to do if $pkgname has exported any constants. See c<sub on_reload> for example usage.

Compilation errors

All warnings during the recompilation will be hidden. If the compilation failes, they will be shown along with the compilation error messages.

The previous version of the module will remain in memory and continue being used. This gives you time to correct the errors, without any interruptions, if possible.

import

register_module

check_for_updates

reload

  Para::Frame::Reload->reload( $module, $mtime )

$module is the filename given to require

call_import

modules_importing_from_us

package_to_module

NOTE: Defined in Para::Frame::Utils but given here to avoid cyclic dependency

module_to_package

SEE ALSO

Para::Frame