Skip to content

Commit 8b75ac0

Browse files
committed
Bug fix Sling Reactive clearSubscription
* Bug fix Sling Reactive clearSubscription. * Bump version to 20.3.1. * Add automated test for Sling Reactive bringing the total to 198.
1 parent aea0026 commit 8b75ac0

12 files changed

+47
-20
lines changed

dist_sling/sling-reactive.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist_sling/sling.es5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ var l = function l(_ref3) {
629629
}), t;
630630
};
631631
function version() {
632-
return "20.3.0";
632+
return "20.3.1";
633633
}
634634
var E = function E(t, e) {
635635
return t.split(e).length - 1;

dist_sling/sling.min.es5.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist_sling/sling.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist_sling/sling.min.nomodule.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist_sling/sling.slim.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sling.js",
3-
"version": "20.3.0",
3+
"version": "20.3.1",
44
"description": "Client-side JavaScript framework for building Single Page Applications.",
55
"main": "index.js",
66
"scripts": {

src/globalTests.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13035,6 +13035,33 @@ export class GlobalTestRunner {
1303513035
window.globalTestCount++;
1303613036
}
1303713037

13038+
testClearSubscriptionForSubjectWorks() {
13039+
const result = {
13040+
test: 'test clearSubscription for BehaviorSubject works',
13041+
success: false,
13042+
message: ''
13043+
};
13044+
13045+
const sub = BehaviorSubject(0);
13046+
let subscriberRuns = 0;
13047+
const subscriber = () => {
13048+
subscriberRuns++;
13049+
};
13050+
const subscriberToClear = () => {
13051+
return;
13052+
};
13053+
sub.subscribe(subscriber);
13054+
sub.subscribe(subscriberToClear);
13055+
sub.next(1);
13056+
sub.clearSubscription(subscriberToClear);
13057+
sub.next(2);
13058+
13059+
result.success = subscriberRuns === 2;
13060+
13061+
window.globalTestResults.push(result);
13062+
window.globalTestCount++;
13063+
}
13064+
1303813065
testAfterInitListExists() {
1303913066
const result = {
1304013067
test: 'test internal slAfterInit list exists',

src/sling/core/sling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ const _mountInternal = (target, component, attachDetector) => {
11151115
}
11161116

11171117
export function version() {
1118-
return '20.3.0';
1118+
return '20.3.1';
11191119
}
11201120

11211121
function xmur3(str) {

src/sling/core/sling.slim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ const _mountInternal = (target, component, attachDetector) => {
10471047
}
10481048

10491049
export function version() {
1050-
return '20.3.0';
1050+
return '20.3.1';
10511051
}
10521052

10531053
export function resolveAll(promiseArr) {

src/sling/reactive/sling-reactive.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export const Observable = (array) => {
22
const arrFns = ['pop', 'push', 'reverse', 'shift', 'unshift', 'splice', 'sort', 'map', 'filter', 'fill', 'copyWithin'];
33
const noReturnFns = arrFns.slice(0, 6);
44
const observeOps = {};
5-
const subscribedFns = [];
6-
5+
6+
let subscribedFns = [];
77
let data = array;
88
let subCallCount = 0;
99

@@ -62,7 +62,7 @@ export const Observable = (array) => {
6262
const filteredFns = subscribedFns.filter(currFn => currFn !== fn);
6363
this.clearSubscriptions();
6464

65-
subscribedFns.concat(filteredFns);
65+
subscribedFns = subscribedFns.concat(filteredFns);
6666

6767
return this;
6868
}
@@ -89,8 +89,8 @@ export const Observable = (array) => {
8989

9090
export const BehaviorSubject = (value) => {
9191
const subjectOps = {};
92-
const subscribedFns = [];
93-
92+
93+
let subscribedFns = [];
9494
let data = value;
9595

9696
const callCallback = function () {
@@ -110,7 +110,7 @@ export const BehaviorSubject = (value) => {
110110
const filteredFns = subscribedFns.filter(currFn => currFn !== fn);
111111
this.clearSubscriptions();
112112

113-
subscribedFns.concat(filteredFns);
113+
subscribedFns = subscribedFns.concat(filteredFns);
114114

115115
return this;
116116
}
@@ -146,8 +146,8 @@ export const Stream = () => {
146146
const dependentFns = [];
147147
const data = [];
148148
const streamOps = {};
149-
const subscribedFns = [];
150-
149+
150+
let subscribedFns = [];
151151
let length = 0;
152152

153153
const react = function () {
@@ -209,7 +209,7 @@ export const Stream = () => {
209209
const filteredFns = subscribedFns.filter(currFn => currFn !== fn);
210210
this.clearSubscriptions();
211211

212-
subscribedFns.concat(filteredFns);
212+
subscribedFns = subscribedFns.concat(filteredFns);
213213

214214
return this;
215215
}

0 commit comments

Comments
 (0)