jaguar_hotreload 2.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

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 #

2.0.1 #

  • Dart 2 compatibility

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;

Future<void> main() async {
  final reloader = HotReloader()..addPath('.');
  await reloader.addPackageDependencies();
  await reloader.go();

  Timer.periodic(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: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Nov 5, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:jaguar_hotreload/jaguar_hotreload.dart with components: io, isolate.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (vm_service_lib).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
glob ^1.1.3 1.2.0
vm_service_lib ^0.3.5 0.3.10+2 3.22.2+1
watcher ^0.9.7 0.9.7+12
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
js 0.6.1+1
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
pedantic ^1.1.0 1.8.0+1
test ^1.0.0