Skip to content

Redux-like implementation for .NET, inspired by Dart Redurx

License

Notifications You must be signed in to change notification settings

raybarrera/raydux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raydux.NET

using Flux;
using System;

namespace FluxSample {
    class State {
        private readonly int count;
        public int Count => count;

        public State(int count) {
            this.count = count;
        }

        public override string ToString() {
            return count.ToString();
        }
    }

    class Increment : IAction<State> {
        private readonly int by;

        public Increment(int by = 1) {
            this.by = by;
        }

        public State Reduce(State state) {
            return new State(state.Count + by);
        }
    }

    class Program {
        static void Main(string[] args) {
            Store<State> store = new Store<State>(new State(0));

            store.OnStateChanged += () =>
            {
                Console.WriteLine(store.State.Count);
            };

            store.Dispatch(new Increment());
            Console.ReadLine();
        }
    }
}

About

Redux-like implementation for .NET, inspired by Dart Redurx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages