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

[Feature Request] - Refactor API #174

Open
nelwincatalogo opened this issue Aug 19, 2024 · 1 comment
Open

[Feature Request] - Refactor API #174

nelwincatalogo opened this issue Aug 19, 2024 · 1 comment

Comments

@nelwincatalogo
Copy link

Is it possible to do it like this?

import * as React from "react";
import { UIStore } from "./UIStore";

export const App = () => {
  const isDarkMode = UIStore.useState(s => s.isDarkMode);

  return (
    <div
      style={{
        background: isDarkMode.value ? "black" : "white",
        color: isDarkMode.value ? "white" : "black",
      }}>
      <h1>Hello Pullstate</h1>
      <button
        onClick={() =>
          isDarkMode.update(s => {
            s = !isDarkMode;
          })
        }>
        Toggle Dark Mode
      </button>
    </div>
  );
};
@lostpebble
Copy link
Owner

It kinda goes against the simplified object concept of the library, both for reads and updates.

Please give more information as to why this API of yours is useful? Expand a bit on the idea behind it. It just seems like it adds more complexity / unnecessary code.

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

No branches or pull requests

2 participants