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

feat(wire-service): rfc implementation #166

Merged
merged 54 commits into from
Mar 26, 2018
Merged

feat(wire-service): rfc implementation #166

merged 54 commits into from
Mar 26, 2018

Conversation

yungcheng
Copy link
Contributor

Details

implements #148

Does this PR introduce a breaking change?

  • Yes
  • No

@kevinv11n kevinv11n self-requested a review March 20, 2018 21:29
return {
updatedCallback: (newConfig) => {
config = newConfig;
subscription = getObservable(config).subscribe({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any time this code gets a new subscription, it should call subscription.unsubscribe() if subscription is defined and non-null. Wire adapter implementors may mess that up when dealing with raw Observables, so it's important to highlight that.

buildContext
} from './wiring';
export interface WiredValue {
data?: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we be more specific here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WiredValue: any

removeEventListener(type: string, listener: WireEventTargetListener): void;
}

export type WireAdapterFactory = (eventTarget: WireEventTarget) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably rename this to WireAdapterCallback since it is not a factory anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not really a callback either, it's more like a setup... which factory kinda make sense, but i understand it's not returning a lifecycle hook object so it's not a factory.

if (adapterFactory) {
const wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why is all these important. Eventually we can iron this out! not a big deal.

* @param paramValues values for all wire adapter config params
*/
function invokeConfigListeners(configListenerMetadatas: Set<ConfigListenerMetadata>, paramValues: any) {
for (const metadata of configListenerMetadatas) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid using iterators. let's use a regular for loop


function updated(cmp: Element, prop: string, configContext: ConfigContext) {
if (!configContext.mutated) {
configContext.mutated = new Set<string>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need a Set? can a regular array make the cut so we can just use for-loop on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has to be a set to dedupe

if (!configContext.mutated) {
configContext.mutated = new Set<string>();
// collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe an arrow here is better than an actual bind

Copy link
Contributor

@caridy caridy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside from the small issue with for-of, I think we are good! Also, lets make sure that we do a quick pass on the ES5 version of the transpiled code so feel comfortable with it.

@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: 1d3963d | Target commit: d234b6a

benchmark base(1d3963d) target(d234b6a) trend
table-append-1k.benchmark:benchmark-table/append/1k 262.33 (± 5.81 ms) 258.15 (± 4.70 ms) 👍
table-clear-1k.benchmark:benchmark-table/clear/1k 14.85 (± 0.56 ms) 13.93 (± 0.38 ms) 👍
table-create-10k.benchmark:benchmark-table/create/10k 1572.12 (± 28.04 ms) 1476.58 (± 26.20 ms) 👍
table-create-1k.benchmark:benchmark-table/create/1k 171.76 (± 9.69 ms) 162.65 (± 4.79 ms) 👍
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 133.77 (± 3.46 ms) 133.53 (± 4.47 ms) 👌
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 330.69 (± 6.11 ms) 341.26 (± 5.48 ms) 👎
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 33.78 (± 1.22 ms) 34.95 (± 0.88 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2503.03 (± 35.28 ms) 2642.32 (± 60.75 ms) 👎
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 285.53 (± 8.90 ms) 287.33 (± 8.02 ms) 👌
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 127.45 (± 4.70 ms) 121.48 (± 2.75 ms) 👍

@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: 1d3963d | Target commit: f85f8c9

benchmark base(1d3963d) target(f85f8c9) trend
table-append-1k.benchmark:benchmark-table/append/1k 262.33 (± 5.81 ms) 263.46 (± 7.22 ms) 👌
table-clear-1k.benchmark:benchmark-table/clear/1k 14.85 (± 0.56 ms) 13.56 (± 0.71 ms) 👍
table-create-10k.benchmark:benchmark-table/create/10k 1572.12 (± 28.04 ms) 1429.98 (± 12.04 ms) 👍
table-create-1k.benchmark:benchmark-table/create/1k 171.76 (± 9.69 ms) 149.28 (± 2.29 ms) 👍
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 133.77 (± 3.46 ms) 119.51 (± 1.53 ms) 👍
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 330.69 (± 6.11 ms) 324.27 (± 3.62 ms) 👍
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 33.78 (± 1.22 ms) 33.15 (± 1.02 ms) 👌
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2503.03 (± 35.28 ms) 2438.32 (± 16.05 ms) 👍
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 285.53 (± 8.90 ms) 274.39 (± 5.98 ms) 👍
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 127.45 (± 4.70 ms) 122.74 (± 2.84 ms) 👌

@yungcheng yungcheng merged commit b1b89e0 into master Mar 26, 2018
@yungcheng yungcheng deleted the wire-rfc-impl branch March 26, 2018 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants