Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wire-service): compat integration tests #178

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/lwc-integration/src/shared/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ exports.todoApp = function (cmpName) {

// Register the wire adapter for @wire(getTodo).
registerAdapter(getTodo, function getTodoWireAdapter(wiredEventTarget) {
let subscription;
let config;
var subscription;
var config;
wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data: undefined, error: undefined }));
const observer = {
next: data => wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data, error: undefined })),
error: error => wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data: undefined, error }))
var observer = {
next: function(data) { wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data: data, error: undefined })); },
error: function(error) { wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data: undefined, error: error })); }
};
wiredEventTarget.addEventListener('connect', () => {
const observable = getObservable(config);
wiredEventTarget.addEventListener('connect', function() {
var observable = getObservable(config);
if (observable) {
subscription = observable.subscribe(observer);
return;
}
});
wiredEventTarget.addEventListener('disconnect', () => {
wiredEventTarget.addEventListener('disconnect', function() {
subscription.unsubscribe();
});
wiredEventTarget.addEventListener('config', (newConfig) => {
wiredEventTarget.addEventListener('config', function(newConfig) {
config = newConfig;
if (subscription) {
subscription.unsubscribe();
subscription = undefined;
}
const observable = getObservable(config);
var observable = getObservable(config);
if (observable) {
subscription = observable.subscribe(observer);
return;
}
});
});

const element = createElement('${cmpName}', { is: Cmp });
var element = createElement('${cmpName}', { is: Cmp });
document.body.appendChild(element);
`;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/lwc-wire-service/src/property-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ function updatedFuture(cmp: Element, configContext: ConfigContext) {
// configContext.mutated must be set prior to invoking this function
const mutated = configContext.mutated as Set<string>;
delete configContext.mutated;
for (const prop of mutated) {
mutated.forEach(prop => {
const value = cmp[prop];
if (configContext.values[prop] === value) {
continue;
return;
}
configContext.values[prop] = value;
const listeners = configContext.listeners[prop];
for (let i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
}

Expand Down