Skip to content

Commit

Permalink
removed .origin and .nextSource
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Eiten committed Aug 17, 2017
1 parent 4e6655e commit 09cfd65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
29 changes: 11 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ DataSourceBase.prototype = {
this.dataSource = dataSource;
},

postInitialize: function() {
if (this.dataSource) {
this.dataSource.nextSource = this;
} else {
DataSourceBase.prototype.origin = this;
}
},

// GETTERS/SETTERS

get schema() {
Expand Down Expand Up @@ -181,29 +173,30 @@ DataSourceBase.prototype = {
unsubscribe: pubsubstar.unsubscribe,

publish: function(topic, message) {
var dataSource, nextDataSourcePropertyName,
var methodName = topic.replace(regexHyphenation, toCamelCase),
dataSources = [],
results = [];

if (!(typeof topic === 'string' && topic.indexOf('*') < 0)) {
throw new TypeError('DataSourceBase#publish expects topic to be a string primitive sans wildcards.');
}

if (this.publishDirection[topic]) {
dataSource = this;
nextDataSourcePropertyName = 'dataSource';
} else {
dataSource = this.origin;
nextDataSourcePropertyName = 'nextSource';
for (var dataSource = this; dataSource.dataSource; dataSource = this.dataSource) {
dataSources.push(dataSource);
}
dataSources.push(dataSource);

if (!this.publishDirection[topic]) {
dataSources.reverse();
}

for (; dataSource; dataSource = dataSource[nextDataSourcePropertyName]) {
var methodName = topic.replace(regexHyphenation, toCamelCase)
dataSources.forEach(function(dataSource) {
if (typeof dataSource[methodName] === 'function') {
results.push(dataSource[methodName](message));
} else {
results.push(pubsubstar.publish.call(dataSource, topic, message));
}
}
});

return results;
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fin-hypergrid-data-source-base",
"version": "1.0.1",
"version": "1.0.2",
"description": "Base class for Hypergrid cascading \"data source\" modules.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 09cfd65

Please sign in to comment.