boardgameio / boardgame.io

State Management and Multiplayer Networking for Turn-Based Games
https://boardgame.io
MIT License
9.93k stars 707 forks source link

Reduce API Surface: Hide Game()? #288

Closed Izhaki closed 4 years ago

Izhaki commented 5 years ago
  1. There might be a good reason for this which is beyond me.
  2. Yes, it's a breaking change!

But still...


From the docs:

import { Client } from 'boardgame.io/react';
import { Game } from 'boardgame.io/core';

const TicTacToe = Game({
  setup: () => ({ cells: Array(9).fill(null) }),
  // ...
});

const App = Client({ game: TicTacToe });

Why do we need to import Game and call it?

Why not just:

import { Client } from 'boardgame.io/react';

const TicTacToe = {
  setup: () => ({ cells: Array(9).fill(null) }),
  // ...
);

const App = Client({ game: TicTacToe });

And have Client invoking Game?

I've looked throughout the docs and couldn't find why not doing it this way.

nicolodavis commented 5 years ago

This is a good idea. Game does do some initialization work, but Client and Server can just call Game internally and it would be a pretty simple change to implement.

Do you have time to make a PR for this?

Izhaki commented 5 years ago

Guess I could.

How do you envision it? Mainly:

nicolodavis commented 5 years ago

Let's just make a clean break and move over to the new proposed version.

We're still in alpha so people should expect breaking changes. As long as we document it clearly in the changelog, things should be fine.

nicolodavis commented 4 years ago

This was fixed as part of the "phases-overhaul" effort.