Giter Site home page Giter Site logo

aleclarson / react-galaxy Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 17 KB

Reactive rendering via immutable copies (powered by immer 👉https://goo.gl/t7gJPr), and more! -- Guide/documentation 👉https://react-galaxy.github.io

License: MIT License

TypeScript 100.00%
react immer immutable reactive rendering

react-galaxy's Introduction

react-galaxy v0.1.0

Powered by TypeScript and immer.

Do you like "render props", but hate "callback hell"? Try yender with react-galaxy.

 


 

Reactive selectors

"Selectors" are functions that take some arguments (often observable) and return some value (which is then deep frozen). The return value is provided to a React component (using render props) or another selector (using the derive function).

The "reactive" part means anything a selector accesses (from its arguments or any galaxy) is observed whenever possible. Every time an observed value changes, the selector is called. Every time the selector returns a value that's different from its previous return value, anything observing the selector is notified.

 


 

Observable and immutable? What?

Whenever immer copies an immutable object, Galaxy notifies the observable object, which then calls its observers. An object must be made observable before being frozen, and our track function does both for you.

The observable object always points to the newest copy of the "base state" (which is whatever object you passed to track). This means you get the power of immutability and observability.

The track function always returns the same value you passed in. All it does is tag the given value and any nested objects/arrays with observable objects.

 


 

But wait, there's more! The guide is a must-read.

Contributors wanted!

 

MIT License

Copyright (c) Alec Larson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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.