Git Product home page Git Product logo

reactpy's People

Contributors

acivitillo avatar archmonger avatar daemo00 avatar danish-mehmood avatar dependabot[bot] avatar elro444 avatar eltociear avatar geckguy avatar iddorot avatar jensenbox avatar jmtaysom avatar kianmeng avatar kurtsley avatar liberty-rising avatar mrjunos avatar not-sarthak avatar philippjfr avatar rmorshea avatar smit-parmar avatar stefanbrand avatar zeus-03 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  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

reactpy's Issues

Event Occurs After Handler is Deleted

Consider a case where a button click causes that button to be re-rendered. In this scenario, after the first click the backend will begin work to render again and eventually will delete state for the original button element. If shortly after the first button click a user clicks again it is possible that the button in the view and the button model in the backend are not the same. The event produced by this last click will result in an error because the element that would normally have handled it has already been deleted.

In particular we get a key error here:

https://github.com/rmorshea/idom/blob/b21f8e8361ced41508fb80afab4d5efe69c423fe/src/py/idom/layout.py#L60

Doc Build Warnings Should Cause Failures

https://travis-ci.com/rmorshea/idom/jobs/258370959

WARNING: Cannot resolve forward reference in type annotations of "idom.core.element.element": name 'VdomDict' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.core.element.AbstractElement.mount": name 'AbstractLayout' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.core.element.Element": name 'VdomDict' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.core.element.Element.mount": name 'AbstractLayout' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.server.base.AbstractRenderServer": name 'Element' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.server.sanic.SanicRenderServer": name 'Element' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.server.sanic.PerClientState": name 'Element' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.server.sanic.SharedClientState": name 'Element' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.widgets.common.EvalElement.mount": name 'AbstractLayout' is not defined
WARNING: Cannot resolve forward reference in type annotations of "idom.widgets.inputs.Input.mount": name 'AbstractLayout' is not defined
WARNING: Cannot treat a function defined as a local function: "idom.widgets.html.html"  (use @functools.wraps)
WARNING: Cannot resolve forward reference in type annotations of "idom.widgets.html.html": name 'EventHandlerFunction' is not defined

Add CLI to IDOM for Installing Dependencies

The programmatic API is nice for installing dependencies on the fly, but in production I can't imagine anyone would ever do it that way. You'd want a CLI command you could run to install things ahead of time.

Intro notebook has bad example in markdown

This:

async def InputWithShareableValue(self, value=""):

    async def changed(event):
        # this update is sent to all clients
        self.update(value)

    return idom.html.input(value=value, onChange=changed)

should be updated to:

async def InputWithShareableValue(self, value=""):

    async def changed(event):
        # this update is sent to all clients
        self.update(event["value"])

    return idom.html.input(value=value, onChange=changed)

Add ability to install and import arbitrary JS packages

While you can technically use idom.Import to import JS packages via URL and use them inside an application, this feature is a bit broken. For example, Material UI (imported from jspm) does not work. I'm not entirely sure of why this might be, but I suspect it has to do with the fact that importing it in this way creates two React instances that conflict with each other. From what I can tell, the only real solution is to provide a simple wrapper around NPM and some sort of bundler-like technology to install dependencies so they can be imported on the fly.

The most promising option I can see at the moment is Snowpack (probably because it seems like the most approachable to me). My plan for this is to rewrite the current client so it's ES6 compliant and then write a simple wrapper in Python that can install the dependencies with npm, build them into ES6 modules with snowpack and then serve them as part of the application. This will only work if the user installs npm of course, however that seems like a fairly reasonable requirement for this sort of feature.

Change Basic Node Constructor Interface

idom.node allows you to pass children via *args and attributes via **kwargs. I think it would be cleaner to use if the interface was:

idom.node([...children], {...attributes})

Which makes it easier to specify attributes which are Python keywords (e.g. class which is proxied by cls now).

Validate VDOM Using JSON Schema

The JSON schema from the docs should be used to validate VDOM returned by layouts. We can add it to the tests and create a mock the wraps the layout's render function so that it validates every output.

Views Disapear After Refreshing Jupyter Notebook

This was actually intentional, but should really be a temporary solutions since it's rather inconvenient. In short we did this because requesting a resource from a different origin must be successful otherwise future requests to that resource will be blocked by the browser.

So if you restarted your kernel and refreshed the notebook page your IDOM widget views would fail to display when you re-ran it because the pre-existing view attempted to connect to the IDOM webserver when it didn't exist yet.

To work around this we temporarily displayed a script that set document.idomServerExists = true so that views could check that flag before they displayed. This will be changed soon though.

Unregister Animation Callback on Unmount

Animation callbacks should be unregistered from a layout when the element that saved it is unmounted. Once the element is unmounted there's no point in keeping the animation callback around since the element will never be shown again.

Animation callbacks proliferate in the introductory notebook if you repeatedly display the Snake Game. Eventually the notebook will slow down significantly since the animation callbacks reregister themselves indefinitely.

Element Won't Render More Than Once

This pattern is not allowed right now:

@idom.element
def GetsRenderedTwice(self):
    return idom.html.div()

@idom.element
def CauseSecondRender(self, node):
    events = idom.Events()

    @event.on("Click")
    def render_again():
        self.update(node)

    return node

This is because CauseSecondRender uses the same instance of GetsRenderedTwice and causes an error. We should not raise an error when this occurs though. Not sure why that limitation was put in there.

Here's where the error occurs:

https://github.com/rmorshea/idom/blob/1078cd4ccfce761392b4774340597dc4479e53cd/src/py/idom/core/element.py#L207

Doc enhancement: readthedocs examples broken

The examples at https://idom.readthedocs.io/en/latest/examples.html seem to be based on an older version of code and there are some API changes that break many (maybe all?) of them.

For example in the To Do List example creates callbacks for events like this:

task_input = idom.html.input(onKeyDown=add_new_task)

... ...

delete_button = idom.html.td(idom.html.button("x"), onClick=remove)

but the current API has you pass the callbacks as a dictionary

Something like:

task_input = idom.html.input({'onKeyDown':add_new_task})

Doc Enhancement

Describe what's wrong with the documentation
Broken link "here" in "Getting Started" section - this should link to React, or an internal page.

Screenshots
image

Get to 100% coverage

This would just be nice to have. Doing this later will only become more difficult.

Add Frame Pacing Utility

The following will allow animation callbacks to produce frame with relatively consistent timing.

import time
import asyncio


class FramePace:
    
    def __init__(self, rate):
        self._rate = rate
        self._last = time.time()
    
    async def wait(self):
        await asyncio.sleep(self._rate - (time.time() - self._last))
        self._last = time.time()

Remove Asyncio

While the asyncio API looks nice and shiny to me, I've heard some feedback, that given the audience idom might serve, the async/await syntax might scare them off. Additionally, expensive backend processes block renders of minor changes. For example, the matplotlib example blocks updates to the sliders when the graph image is being created this causes the moving sliders to jitter each time the graph updates.

Add Test For Introduction Notebook

We should at least try to execute all the cells in the into notebook. This will catch a lot of errors that might occur there due to breaking API changes. #125 is a good example of a breaking API change that wasn't modified in the intro notebook.

Add Selenium Tests

Write tests with selenium. Unit tests are helpful, but it would be good to get an end to end test in that covers the Javascript as well.

Allow Multiple Active Views in Jupyter Notebook

This limitation is due to the fact that there was no way to provide per-client parameters. Enabling clients to pass parameters to IDOM elements upon connection would enable them to display a unique view to each client based on which parameters were passed. There are probably other use cases for per-client view parameters beside just in the Jupyter Notebook so this is definitely worth doing.

Only One Event Handler Per Element

There's a bug in the way event handlers are set up that assigns all event handlers under the same target ID. Thus registering handlers to more than one event type causes a conflict.

Animation Hook Never Stops

Fix bug in animation where you could register a new animation hook after stopping the original hook (i.e. by returning False). We solve this by marking whether or not an element's animation hook has stopped. If you register a hook after a prior one has stopped then a RuntimeError will be raised.

We also change the animation API by passing in a stop function. Once the stop function has been called then the animation hook will not be called again and no new animation hooks can be registered to the element.

Client Side Python Components

Because of ReactPy's granular core abstractions it should be possible to run ReactPy client-side with Pyodide or PyScript. Using ReactPy instead of a solution that relies on a transpiler could have some advantages:

  • Components can be run client-side or server-side without any changes
  • No need to fiddle with weird bugs caused by back transpilation

ReactPy's client already uses React to render its JSON serializable VDOM into an actual view, so if the DOM representation were already client-side (as it would be with Pyodide) it should be trivial to send that representation to React directly rather than over a websocket.

Here is a functioning gist that uses ReactPy client-side via PyScript: https://gist.github.com/rmorshea/c888e6e34519edababf49351c63c335e

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.