Coder Social home page Coder Social logo

vobyjs / voby Goto Github PK

View Code? Open in Web Editor NEW
867.0 10.0 22.0 5.16 MB

A high-performance framework with fine-grained observable-based reactivity for building rich applications.

Home Page: https://voby.dev

License: MIT License

TypeScript 100.00%
ui framework reactive observable fast performant small fine-grained voby

voby's People

Contributors

andreichuk avatar brandonbritton avatar cmemery avatar fabiospampinato avatar high1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voby's Issues

Template seems not to support children props

Here's a template for a Row:

export const Row = template(
  (props: { style?: JSX.StyleProperties; children?: JSX.Children }) => {
    props = {
      ...props,
      style: {
        display: "flex",
        flexDirection: "row",
        ...props.style,
      },
    };
    return <div {...props} />;
  },
);

Example usage:

<Row>test</Row>

Renders:

<div style="display: flex; flex-direction: row;"></div>

Expected:

<div style="display: flex; flex-direction: row;">test</div>

ObservableReadonly creation from Observable

How is it supposed to create ObservableReadonly<T> from Observable<T>? Is there anything similar to $.readonly(someObservable) utility from oby lib? I saw ObservableAbstract<T, Ti> type has readonly prop but its return type is ObservableReadonlyAbstract<T, TI>, not ObservableReadonly<T>.

HMR Support

Hello, for many use cases having a true HMR would be amazing. Direct manipulation editors for example.

VOBY_HMR: If true, then Voby will catch errors that happen during diffing and log them to the console instead, keeping your page working after an HMR update event in some case. Fine-grainined support for HMR is not implemented (yet?).

But as far as I can see it's not implemented yet? What kind of pitfals should one expect with HMR while using voby?

JSDoc comments

I might be useful to provide JSDoc comments for the exported functions.

Usage scenarios for Directive

Recently I've been doing some visualization work and I've been passing const useChart => (opts) => el => {} to <div ref={} />, Directive can do something similar but it looks more complicated, I'd like to know in what scenarios Directive should be used?

createDirective type reduced in .d.ts

The generic parameter T extends keyof JSX.Directives has collapsed to T extends never in the .d.ts file.

declare const createDirective: <T extends never>(name: T, fn: DirectiveFunction<JSX.Directives[T]>, options?: DirectiveOptions) => Directive<T>;

I think this is an issue with the TypeScript compiler. Perhaps we need to find a way to work around it and keep the normal generic parameters.

Support reparenting KeepAlive instances

In order for KeepAlive to work perfectly with the context it has to get reparented when rendered somewhere else, and the context has to be updated, which is not really possible given how the context works today.

This should also fix how errors bubble up.

Simplifying the type signature of useResolved

I tested the following type signature, and it correctly inferred the list of variable parameter types, so maybe we can use it to simplify the signature of the useResolved function.

function resolve<
  T extends unknown[],
  R extends {
    [K in keyof T]: T[K] extends Observable<infer V> ? V : T[K] extends () => infer V ? V :  T[K]
  },
>(vals: [...T], fn: (...args: [...R]) => void) {


}

resolve([$(1), $('2'), 3, () => 4], (_1, _2,_3, _4) => {

})
image

Improving types for directives

  • One should be able to say which kinda of elements a directive works with.
  • Inferred types for createDirective and Directive.ref should be perfect.

createContext with a factory lambda

Currently, we have:

function createContext <T> ( defaultValue?: T ): Context<T>;

That means all instances of the context have the same defaultValue.

It would be nice to have:

function createContext <T> ( factory: () => T ): Context<T>;

Custom Renderer

Is it possible to implement the createRenderer API in solid in voby? This allows voby to be used in a wider range of scenarios.

Enhance the type of createDirective

Thanks for the tip in #20 , I played with it a bit, it's really handy, I suggest to improve the type of createDirective to make it more typeify, here is my code, it provides name and opts type

image

Sierpinski triangle demo is missing per-node expensive computation

Hello, just a thought about the rendering performance demo:

https://codesandbox.io/s/voby-demo-triangle-l837v0?file=/src/index.tsx:222-385

const useSeconds = (): Observable<number> => {

  const seconds = $(0);

  useInterval ( () => seconds ( ( seconds () % 9 ) + 1 ), 1000 );

  return seconds;
};

I think that useSeconds() should be "wrapped" into an intermediary observable that triggers at the same time as the seconds signal which is scheduled to reliably fire at every seconds tick. The goal of this "wrapper" observable is to introduce a computationally-taxing operation, per node of the triangular structure (just as in the original React demo).

This is specifically what makes this stress-test relevant, as remarked by Ryan Carniato:

https://github.com/ryansolid/solid-sierpinski-triangle-demo#solid-sierpinski-triangle-demo

See:

https://github.com/ryansolid/solid-sierpinski-triangle-demo/blob/889db98d7697bd39d8fe3ca0e0134fb2788b4447/src/main.jsx#L46-L51

    var e = performance.now() + 0.8;
    // Artificially long execution time.
    while (performance.now() < e) {}
};

(sorry, I don't know enough about Voby to contribute a PR)

I used the same technique in my stress-test for fine-grain reactivity / observable lib experiment (I use uHTML for DOM rendering). Otherwise, rendering at 200 FPS is way too easy :)

JSX ref

Is JSX's 'ref' attribute supported? In the following example it does nothing:

// voby 0.16

const App = () => {
    let eInput;

    function onClick() {
        console.log("eInput: " + eInput); // outputs 'eInput: undefined'
    }

    return (
        <input type="text" ref={eInput} onClick={onClick}/>
    )
};

render(<App />, document.body);

Proper documentation

Once we get the website up and running some proper documentation should be hosted in it.

preactjs-signals style API?

voby is perfect for embedding in my application, thank you for making this!

signal() / atom() and atom.value style getters and setters seem easier to understand, I hope to consider this.

`batch` is global

Hi @fabiospampinato
I've been playing around a bit with Voby and I'm looking to move my app from Solid to Voby potentially. I really need something like Voby's batch behavior. However, I noticed something a little surprising about batch in that it is global. If batch is called, no effects will run for any signals until the callback resolves, not just the signals that are affected in the callback. I found this a bit surprising. It doesn't affect my use case, but I wanted to make you aware. I know Voby isn't at version 1 yet. So if the batch behavior is going to be nerfed by version 1, I'd rather not move to Voby. I already had that experience with Solid, where batch worked in the way I needed as of version 1.3, but as of 1.4, it changed and no longer fit my use case. So I wanted to check on the likelihood of batch seeing serious changes in future. Thoughts?

isServer

An isServer function could be useful, to do different things between the rendering to the DOM and rendering to a string.

`store.unwrap(...)` is not appropriately typed

I like to unwrap stores for logging to the console as the Proxies require a couple extra clicks to see the value. So I'm using store.unwrap but doesn't appear to be part present on the store type. Are you planning on a different unwrap function or do you not want to publicly expose it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.