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

low: make an article about the powerful data flow #47

Open
betula opened this issue Mar 20, 2021 · 1 comment
Open

low: make an article about the powerful data flow #47

betula opened this issue Mar 20, 2021 · 1 comment

Comments

@betula
Copy link
Member

betula commented Mar 20, 2021

import React from "react";
import { value, useLocal, useValue } from "realar";

const Logic = () => {
  const name = value("Joe");
  const inputHandler = name.pre((ev: React.ChangeEvent<HTMLInputElement>) => (
    ev.currentTarget.value
  ));

  return {
    name,
    inputHandler
  }
};


const Form = () => {
  const logic = useLocal(Logic);
  const name = useValue(logic.name);
  
  return (
    <>
      <h1>Hello {name}!</h1>
      <p>
        Name: 
        <input 
          type="text" 
          value={name}
          onChange={logic.inputHandler} />
      </p>
    </>
  );
};

const App = () => (
  <Form />
);

export default App;

Try on CodeSandbox

@betula betula added the documentation Improvements or additions to documentation label Mar 21, 2021
@betula
Copy link
Member Author

betula commented Mar 29, 2021

Example of some api method documentation. Looks like pretty)
https://github.com/shastajs/shasta/blob/master/docs/Store/createStore.md

@betula betula added article proposal and removed documentation Improvements or additions to documentation labels Jun 8, 2021
@betula betula changed the title high: documentation about the powerful data flow low: make an article about the powerful data flow Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant