Skip to content

Commit

Permalink
wip: wire register is broken it was making karma fail
Browse files Browse the repository at this point in the history
  • Loading branch information
jodarove committed Aug 30, 2019
1 parent c9ad2c5 commit a901a64
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement, register } from 'lwc';
import { registerWireService } from 'wire-service';
registerWireService(register);
import { createElement } from 'lwc';
// import { registerWireService } from 'wire-service';
// registerWireService(register);
import { installCustomContext, getValueForIdentity } from 'x/advancedProvider';
import Consumer from 'x/advancedConsumer';
import { setValueForIdentity } from './x/advancedProvider/advancedProvider';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement, register } from 'lwc';
import { registerWireService } from 'wire-service';
registerWireService(register);
import { createElement } from 'lwc';
// import { registerWireService } from 'wire-service';
// registerWireService(register);
import { installCustomContext, setCustomContext } from 'x/simpleProvider';
import Consumer from 'x/simpleConsumer';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
* identity of the consumer is not tracked.
*/

import { register, ValueChangedEvent, LinkContextEvent } from 'wire-service';
import { WireAdapter, ValueChangedEvent, LinkContextEvent } from 'wire-service';

const { addEventListener } = Document.prototype;

const IdentityMetaMap = new WeakMap();
const UniqueEventName = `advanced_context_event_${guid()}`;
const Provider = Symbol('SimpleContextProvider');
// const Provider = Symbol('SimpleContextProvider');

function guid() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}

register(Provider, eventTarget => {
const adapterEventTargetCallback = eventTarget => {
let unsubscribeCallback;

function callback(data, unsubscribe) {
Expand All @@ -47,7 +47,14 @@ register(Provider, eventTarget => {
unsubscribeCallback = undefined; // resetting it to support reinsertion
}
});
});
};

const Provider = class extends WireAdapter {
constructor(dataCallback) {
super(dataCallback);
adapterEventTargetCallback(this.eventTarget);
}
};

function createNewConsumerMeta(provider, callback) {
// identity must be an object that can't be proxified otherwise we
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
*/

// Per Context Component Instance, track the current context data
import { register, ValueChangedEvent, LinkContextEvent } from 'wire-service';
import { WireAdapter, ValueChangedEvent, LinkContextEvent } from 'wire-service';

const { addEventListener } = Document.prototype;

const ContextValueMap = new WeakMap();
const UniqueEventName = `simple_context_event_${guid()}`;
const Provider = Symbol('SimpleContextProvider');
// const Provider = Symbol('SimpleContextProvider');

function guid() {
return Math.floor((1 + Math.random()) * 0x10000)
Expand All @@ -37,7 +37,8 @@ function createContextPayload(value) {
return value;
}

register(Provider, eventTarget => {
// register(Provider, eventTarget => {
const adapterEventTargetCallback = eventTarget => {
let unsubscribeCallback;

function callback(value, unsubscribe) {
Expand All @@ -62,7 +63,14 @@ register(Provider, eventTarget => {
unsubscribeCallback = undefined; // resetting it to support reinsertion
}
});
});
};

const Provider = class extends WireAdapter {
constructor(dataCallback) {
super(dataCallback);
adapterEventTargetCallback(this.eventTarget);
}
};

function getContextData(eventTarget) {
let contextData = ContextValueMap.get(eventTarget);
Expand Down

0 comments on commit a901a64

Please sign in to comment.