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

New component function, refactor TodoMVC #111

Merged
merged 9 commits into from
Aug 24, 2019
Merged

Conversation

paldepind
Copy link
Member

Renames loop to component and makes it handle a return value that allows setting the available output of the resulting component.

Updates the TodoMVC example to use component instead of modelView and refactors it to follow other, IMHO, best practices.

More than 100 lines of code shaved off in the TodoMVC.

@paldepind paldepind changed the title WIP: New component function, refactor TodoMVC New component function, refactor TodoMVC Aug 22, 2019
props?: {
[name: string]: Showable | Behavior<Showable | boolean>;
};
props?: Attributes;
Copy link
Member

Choose a reason for hiding this comment

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

This is not the same, since attributes are HTML attributes and not the properties on the DOMElement.
Since an attribute could be set in the HTML without any value, we need the boolean, however this is not the case for properties on the DOMElement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I didn't notice that changing it added boolean to props. But, I've looked it up the documentation here and there are actually a couple of boolean-valued properties: spellcheck, translate, draggable, hidden, and more. So maybe this change is actually ok after all?

const valueB: any = b[key];
if (valueA !== undefined) {
if (isStream(valueA) && isStream(valueB)) {
(a as any)[key] = valueA.combine(valueB);
Copy link
Member

Choose a reason for hiding this comment

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

Nice 😃

@paldepind paldepind merged commit f651b1c into master Aug 24, 2019
@paldepind paldepind deleted the new-component-function branch August 24, 2019 05:17
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

2 participants