Skip to content

Commit

Permalink
Add CHANGELOG, LICENSE and README
Browse files Browse the repository at this point in the history
  • Loading branch information
neilsarkar committed Jul 20, 2020
1 parent 2e8fa55 commit bafba0e
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2020-07-19

### Added
- View
- RepeatView
7 changes: 7 additions & 0 deletions CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright 2020 Neil Sarkar

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.

7 changes: 7 additions & 0 deletions LICENSE.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Violet UI

State-based rendering with live updates in the Unity Editor

## State

```csharp
using Dispatch;

[System.Serializable]
public class UIState : State {
public int nice;
}
```

## Actions

```csharp
using System;

public static class UIActions {
public static Action<UIState> IncrementNice => state => {
state.nice++;
}

public static Action<UIState> SetNice(int nice) => state => {
state.nice = nice;
}
}
```

## View
```csharp
using VioletUI;

public class MyBaseView : View<UIState> {
// pull state from gameObject, singleton, disk etc
UIState state = new UIState();
public override UIState State => state

// provide a copy of the state to use for history
UIState lastState = new UIState();
public override UIState LastState => lastState;
}

public class AddView : MyBaseView {
// Render is called every time the state changes
public override void Render(UIState state, UIState lastState) {
// only render when the part of the state u care about changes
if (state.nice == lastState.nice) { return; }

print($"State of nice changed to {state.nice}");
}
}

public class AddButtonView : MyBaseView {
public void Increment() {
dispatcher.Run(UIActions.Increment);
}

public void Set() {
dispatcher.Run(UIActions.Set(0));
}
}
```
7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bafba0e

Please sign in to comment.