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

Better Data Binding #1

Closed
minecrawler opened this issue Jan 12, 2022 · 1 comment
Closed

Better Data Binding #1

minecrawler opened this issue Jan 12, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@minecrawler
Copy link
Contributor

minecrawler commented Jan 12, 2022

Improve data-binding by offering a this.$('.selector').bind('propertyName') method.

A quick brainstorm (code non-functional):

type PropsCoercedToPOrNeverOnO<O, P> = { [k in keyof O]: O[k] extends P ? k : never }[keyof O];
export type PropsOfTypePOnO<P, O> = { [k in PropsCoercedToPOrNeverOnO<P, O>]: O };

class Parent {
    danger = ''

    foo<T extends Parent = this>(this: T, propOfChild: Exclude<keyof PropsOfTypePOnO<T, string>, keyof Parent>) {

    }
}

class Child extends Parent {
    field = ''
    field2 = true
    field3 = 3

    bar() {
        this.foo('field')
    }
}

see playground

@minecrawler minecrawler added enhancement New feature or request help wanted Extra attention is needed labels Jan 12, 2022
@minecrawler
Copy link
Contributor Author

minecrawler commented May 22, 2023

to be honest, I'm thinking about removing data-binding and leaving it to a library more specialized. I'm currently working on a project which puts Preact into Slim-Fit. The result is very nice and builds with Vite.

I also noticed that using Slim-Fit as a small web components wrapper for Tauri Apps (instead of going with StencilJS or similar) opens up a lot of possibilities and I'm only missing IO and state management for web components. Since we finally have a more finalized version of decorators, I may go that route in the future :)

Preact/Slim-Fit example I use inside my Tauri App
import {render} from "preact";
import {SlimFit} from "@maruru/slim-fit";

export class Foo extends SlimFit {
    protected render(): Promise<void> | void {
        const containerEle = document.createDocumentFragment();
        render(
            <h1>Hello World!</h1>,
            containerEle
        );
        this.draw(containerEle, 'h1 { color: red; }');
    }
}

Foo.registerTag('wc-foo');

Top it of with CSS-in-JS, like JSS, and off you go :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant