From 619f9100f212e9da0f1f8c251f5f661dbebdb07f Mon Sep 17 00:00:00 2001 From: Fabbok1x Date: Thu, 29 Nov 2018 19:16:16 +0100 Subject: [PATCH 1/4] Update MysqlSubscription.js --- lib/MysqlSubscription.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/MysqlSubscription.js b/lib/MysqlSubscription.js index 003441f..e672148 100644 --- a/lib/MysqlSubscription.js +++ b/lib/MysqlSubscription.js @@ -1,10 +1,14 @@ // numtel:mysql // MIT License, ben@latenightsketches.com // lib/MysqlSubscription.js +import { Tracker } from 'meteor/tracker'; +import _ from "lodash"; var selfConnection; var buffer = []; + + MysqlSubscription = function(connection, name /* arguments */){ var self = this; var subscribeArgs; @@ -20,6 +24,7 @@ MysqlSubscription = function(connection, name /* arguments */){ subscribeArgs = Array.prototype.slice.call(arguments, 0); name = connection; if(Meteor.isClient){ + connection = Meteor.connection; }else if(Meteor.isServer){ if(!selfConnection){ @@ -32,7 +37,9 @@ MysqlSubscription = function(connection, name /* arguments */){ subscribeArgs = Array.prototype.slice.call(arguments, 1); } - Tracker.Dependency.call(self); + var _tracker = Tracker.Dependency.bind(self); + Object.assign(self, new _tracker()); + // Y U No give me subscriptionId, Meteor?! var subsBefore = _.keys(connection._subscriptions); _.extend(self, connection.subscribe.apply(connection, subscribeArgs)); @@ -47,6 +54,8 @@ MysqlSubscription = function(connection, name /* arguments */){ instance: self, resetOnDiff: false }); + console.log("buffer"); + console.log(buffer); // If first store for this subscription name, register it! if(_.filter(buffer, function(sub){ @@ -54,6 +63,7 @@ MysqlSubscription = function(connection, name /* arguments */){ }).length === 1){ connection.registerStore(name, { update: function(msg){ + var subBuffers = _.filter(buffer, function(sub){ return sub.subscriptionId === msg.id; }); @@ -71,6 +81,7 @@ MysqlSubscription = function(connection, name /* arguments */){ msg.fields && msg.fields.reset === true){ // This message indicates a reset of a result set if(subBuffer.resetOnDiff === false){ + sub.dispatchEvent('reset', msg); sub.splice(0, sub.length); } @@ -94,8 +105,9 @@ MysqlSubscription = function(connection, name /* arguments */){ // Emit event for application sub.dispatchEvent('update', msg.fields.diff, sub); - } - sub.changed(); + + } + sub.changed(msg, newData); } }); } @@ -103,8 +115,11 @@ MysqlSubscription = function(connection, name /* arguments */){ }; // Inherit from Array and Tracker.Dependency -MysqlSubscription.prototype = new Array; -_.extend(MysqlSubscription.prototype, Tracker.Dependency.prototype); +MysqlSubscription.prototype = []; +//_.extend(MysqlSubscription.prototype, Tracker.Dependency.prototype); +MysqlSubscription.prototype.depend = Tracker.Dependency.prototype.depend; //Seems like the only dependency. + + /* * Change the arguments for the subscription. Publication name and connection @@ -236,3 +251,4 @@ function applyDiff(data, diff) { }); } +module.exports = MysqlSubscription; From 866b7167e80ec14878bdab00264463a7fe444414 Mon Sep 17 00:00:00 2001 From: Fabbok1x Date: Thu, 29 Nov 2018 19:16:55 +0100 Subject: [PATCH 2/4] Update LiveMysql.js --- lib/LiveMysql.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/LiveMysql.js b/lib/LiveMysql.js index 11b0144..755e03f 100644 --- a/lib/LiveMysql.js +++ b/lib/LiveMysql.js @@ -5,6 +5,9 @@ var Future = Npm.require('fibers/future'); LiveMysql = Npm.require('mysql-live-select'); +import _ from "lodash"; + + // Convert the LiveMysqlSelect object into a cursor LiveMysql.LiveMysqlSelect.prototype._publishCursor = function(sub) { var self = this; @@ -71,3 +74,5 @@ LiveMysql.LiveMysqlSelect.prototype.fetch = function() { return dataWithIds; } + +module.exports = LiveMysql; From 88270292d0cf9c7fe2aa82c5b3c146bca02d0a35 Mon Sep 17 00:00:00 2001 From: Fabbok1x Date: Thu, 29 Nov 2018 19:17:30 +0100 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e21bf7c..89f69b2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # numtel:mysql [![Build Status](https://travis-ci.org/numtel/meteor-mysql.svg?branch=master)](https://travis-ci.org/numtel/meteor-mysql) -Reactive MySQL for Meteor +Reactive MySQL for Meteor 1.7 Provides Meteor integration of the [`mysql-live-select` NPM module](https://github.com/numtel/mysql-live-select), bringing reactive `SELECT` statement result sets from MySQL >= 5.1.15. From 7745c3a1fe67bbd18cb6f86c645344a0718a7c1e Mon Sep 17 00:00:00 2001 From: Fabbok1x Date: Thu, 29 Nov 2018 19:20:20 +0100 Subject: [PATCH 4/4] Update MysqlSubscription.js --- lib/MysqlSubscription.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/MysqlSubscription.js b/lib/MysqlSubscription.js index e672148..c1d8de3 100644 --- a/lib/MysqlSubscription.js +++ b/lib/MysqlSubscription.js @@ -54,8 +54,6 @@ MysqlSubscription = function(connection, name /* arguments */){ instance: self, resetOnDiff: false }); - console.log("buffer"); - console.log(buffer); // If first store for this subscription name, register it! if(_.filter(buffer, function(sub){