Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guyca/obsidian-tic-tac-toe
A simple game of tic-tac-toe written in React. Uses MVVM and Dependency Injection.
https://github.com/guyca/obsidian-tic-tac-toe
dependency-injection ioc-container mvvm react typescript
Last synced: 3 months ago
JSON representation
A simple game of tic-tac-toe written in React. Uses MVVM and Dependency Injection.
- Host: GitHub
- URL: https://github.com/guyca/obsidian-tic-tac-toe
- Owner: guyca
- License: mit
- Created: 2023-06-28T09:48:55.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-23T17:51:58.000Z (4 months ago)
- Last Synced: 2024-10-24T00:46:45.243Z (4 months ago)
- Topics: dependency-injection, ioc-container, mvvm, react, typescript
- Language: TypeScript
- Homepage:
- Size: 887 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tic-Tac-Toe Game
[![coverage](https://github.com/guyca/obsidian-tic-tac-toe/raw/gh-pages/badges/coverage-jest%20coverage.svg?raw=true)](https://github.com/guyca/obsidian-tic-tac-toe/tree/master/tests)A simple tic-tac-toe game implemented in React using MVVM (Model-View-ViewModel) architecture that utilizes [react-obsidian](https://github.com/wix-incubator/obsidian) for Dependency Injection.
The app demonstrates how dependency injection facilitates writing modular code that is easier to understand and test.
It's adapted from the [Tic-Tac-Toe tutorial](https://react.dev/learn/tutorial-tic-tac-toe) on the React website.
## Key features
- **MVVM Architecture** - The app is structured in a way that separates concerns between the view, view model, and model.
- **Dependency Injection** - The app uses [react-obsidian](https://github.com/wix-incubator/obsidian) for dependency injection.
- **"Dumb views"** - The view is a simple component that only knows how to render the UI. It doesn't contain any business logic.
- **No confusing `useEffect` hooks** - hooks with dependency arrays can be confusing and hard to reason about. This repo demonstrates how to avoid hooks almost entirely by encapsulating logic in classes.## Tests
The repo contains two types of tests:
- [unit](https://github.com/guyca/obsidian-tic-tac-toe/tree/master/tests/unit) - where single components are tested in isolation
- [integration](https://github.com/guyca/obsidian-tic-tac-toe/tree/master/tests/integration) - where the entire app is tested as a whole. Services that interact with the system are mocked in the [FrameworkGraphForIntegrationTests](https://github.com/guyca/obsidian-tic-tac-toe/blob/master/tests/integration/fakes/FrameworkGraphForIntegrationTests.ts).## Running locally
1. yarn
2. yarn dev