Skip to content
This repository

Pass tiny-lr options into client to set reload flags #18

Merged
merged 1 commit into from 7 months ago

2 participants

Earle Castledine Mickael Daniel
Earle Castledine

The motivation behind this patch is to add the liveImg flag, which is needed when you are using images in canvas or webGL. By default, livereload with liveImg=true will only re-set the src of an image - not reload the whole page, which is not useful if you are creating images dynamically and using them in a different context. Though having flags for liveJs and liveCss seems like a good idea too.

Mickael Daniel
Owner

Sounds legit. Sorry for the delay.

I was about to say "Can you add some documentations to the readme for these options" before noticing there is really no documentation at all on options :/

Merging, thanks @mrspeaker

Mickael Daniel mklabs merged commit 8951f20 into from September 24, 2013
Mickael Daniel mklabs closed this September 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 25, 2013
Earle Castledine Pass options into Client 69c33cf
This page is out of date. Refresh to see the latest.
8  lib/client.js
@@ -5,7 +5,8 @@ var WebSocket = require('faye-websocket');
5 5
 
6 6
 module.exports = Client;
7 7
 
8  
-function Client(req, socket, head) {
  8
+function Client(req, socket, head, options) {
  9
+  options = this.options = options || {};
9 10
   this.ws = new WebSocket(req, socket, head);
10 11
   this.ws.onmessage = this.message.bind(this);
11 12
   this.ws.onclose = this.close.bind(this);
@@ -54,8 +55,9 @@ Client.prototype.reload = function reload(files) {
54 55
     this.send({
55 56
       command: 'reload',
56 57
       path: file,
57  
-      liveCss: true,
58  
-      liveJs: true
  58
+      liveCss: this.options.liveCss !== false,
  59
+      liveJs: this.options.liveJs !== false,
  60
+      liveImg: this.options.liveImg !== false
59 61
     });
60 62
   }, this);
61 63
 };
2  lib/server.js
@@ -118,7 +118,7 @@ Server.prototype.handle = function handle(req, res, next) {
118 118
 
119 119
 Server.prototype.websocketify = function websocketify(req, socket, head) {
120 120
   var self = this;
121  
-  var client = new Client(req, socket, head);
  121
+  var client = new Client(req, socket, head, this.options);
122 122
   this.clients[client.id] = client;
123 123
 
124 124
   debug('New LiveReload connection (id: %s)', client.id);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.