GithubHelp home page GithubHelp logo

positive-spaces-io / bindingsrx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grofit/bindingsrx

0.0 0.0 0.0 6.19 MB

A 2 way binding system for unity using unirx

License: MIT License

C# 100.00%

bindingsrx's Introduction

BindingsRx

BindingsRx is a one or two way binding system for unity using unirx.

Discord

It allows you to write more succinct code while showing intent for properties which are bound to other properties, and looks something like this:

myInputField.BindTextTo(someReactiveProperty);
// Changing myInputField.text will update someReactiveProperty and vice versa

Dependencies

Features

  • Supports one and two way binding
  • Helpers for creating your own custom bindings
  • Works with ReactiveProperty<T> and regular values
  • Supports custom processing on binding via IFilter interface
  • Simplifies complex UI interactions, such as binding dropdown options

As mentioned it works with the unirx ReactiveProperty<T> but does not need them, so for example if I had a reactive property I could do:

var myReactiveProperty = new ReactiveProperty<float>(1.0f);
mySlider.BindValueTo(myReactiveProperty);

However if I was working with a 3rd party library I may not have ReactiveProperty objects, so for that I would do:

var myNormalValue = 1.0f;
mySlider.BindValueTo(() => myNormalValue, x => myNormalValue = x);

You can also specify if you want one way or two way bindings explicitly.

var myReactiveProperty = new ReactiveProperty<float>(1.0f);
mySlider.BindValueTo(myReactiveProperty, BindingTypes.OneWay);

Here is an example of making a dropdown in the UI bind to a reactive collection:

var exampleOptions = new ReactiveCollection<string>();
exampleOptions.Add("Option 1");
exampleOptions.Add("Option 2");
exampleOptions.Add("Some Other Option");

someDropdownUIElement.BindOptionsTo(exampleOptions);

Installation

You can take the unitypackage installation file from the relevent release.

Quick Start

  • Install the above package
  • Install UniRx

Running Examples

If you want to run the examples then just clone it and open the unity project in the src folder, then run the examples, I will try to add to as the library matures.

There are also a suite of tests which are being expanded as the project grows.

Docs

See the docs folder for more information. (This will grow)

Other Blurbs

If you like design patterns and practices then there is also a ECS framework built on unirx which can be found @ grofit/ecsrx.

bindingsrx's People

Contributors

grofit avatar

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.