jaguar_hotreload 0.2.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 19

jaguar_hotreload #

Hot reloader for Dart

Docs #

Reloading application on file modification #

[HotReloader] lets the application hot reload itself on modifications to desired files.

main() async {
  final reloader = new HotReloader();
  reloader.addPath('.');
  await reloader.go();

  // TODO your code here!
}

VM service #

[HotReloader] requires that VM service is enabled during program run for reloading to work. To enable VM services supply either --enable-vm-service or --observe command line flag when the application is run.

Failing to do so will result in notHotReloadable exception.

More information can be found at Dart VM

Debouncing #

When there are too many changes, it is not efficient to reload the application for every change. Debouncing allows [HotReloader] to reload only once every specified interval. debounceInterval defaults to once every second.

main() async {
  final reloader = new HotReloader(debounceInterval: const Duration(seconds: 10));
  reloader.addPath('.');
  await reloader.go();

  // TODO your code here!
}

Adding paths to listen #

Using String path #

addPath method shall be used to register file/directory path as [String].

main() async {
    final reloader = new HotReloader();
    reloader.addPath('lib/');
    await reloader.go();
    
    // Your code goes here
}

Using Glob #

addGlob shall be used to register multiple files/directories using a [Glob].

main() async {
    final reloader = new HotReloader();
    reloader.addGlob(new Glob('jaguar_*/lib'));
    await reloader.go();
    
    // Your code goes here
}

Using FileSystemEntity #

addFile shall be used to register a FileSystemEntity.

main() async {
    final reloader = new HotReloader();
    reloader.addFile(new File('pubspec.yaml'));
    await reloader.go();
    
    // Your code goes here
}

Using Uri #

addUri shall be used to register a path using an instance of [Uri].

main() async {
    final reloader = new HotReloader();
    reloader.addUri(new Uri(scheme: 'file', path: '/usr/lib/dart'));
    await reloader.go();
    
    // Your code goes here
}

Using package Uri #

addPackagePath shall be used to register a path using package uri.

main() async {
    final reloader = new HotReloader();
    await reloader.addPackagePath(new Uri(scheme: 'package', path: 'jaguar/'));
    await reloader.go();
    
    // Your code goes here
}

Using package dependencies #

addPackageDependencies shall be used to register all packages the current package depends on.

main() async {
    final reloader = new HotReloader();
    await reloader.addPackageDependencies();
    await reloader.go();
    
    // Your code goes here
}

Manually reloading the application #

reload method is publicly available to request for application reload when desired.

Event #

File modification event #

onChange stream is fired every time there is a change in the registered file paths.

Reload event #

onReload stream is fired after the application is reloaded irrespective of whether the file change or the user triggered the reload.

Changelog #

0.2.3 #

  • Added addPackageDependencies to register all dependent packages
  • Fixed uri path registration
  • Improved README

0.2.1 #

  • First release version

example/jaguar_hotreload_example.dart

// Copyright (c) 2017, teja. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'package:jaguar_hotreload/jaguar_hotreload.dart';

int count = 0;

main() async {
  final reloader = new HotReloader();
  reloader.addPath('.');
  await reloader.addPackageDependencies();
  await reloader.go();

  new Timer.periodic(new Duration(seconds: 1), (_) {
    print(count++);
  });
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jaguar_hotreload: ^0.2.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jaguar_hotreload/jaguar_hotreload.dart';
  
Version Uploaded Documentation Archive
0.2.3 Jul 25, 2017 Go to the documentation of jaguar_hotreload 0.2.3 Download jaguar_hotreload 0.2.3 archive
0.2.2 Jul 25, 2017 Go to the documentation of jaguar_hotreload 0.2.2 Download jaguar_hotreload 0.2.2 archive
0.2.1 Jul 25, 2017 Go to the documentation of jaguar_hotreload 0.2.1 Download jaguar_hotreload 0.2.1 archive
0.2.0 Jul 25, 2017 Go to the documentation of jaguar_hotreload 0.2.0 Download jaguar_hotreload 0.2.0 archive
0.1.0 Jul 23, 2017 Go to the documentation of jaguar_hotreload 0.1.0 Download jaguar_hotreload 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
19
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0