boardgameio / boardgame.io

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

React Native #121

Closed nicolodavis closed 5 years ago

nicolodavis commented 6 years ago

Now that the client logic is decoupled from React, and the React implementation is just a tiny wrapper around the Client class, it should be possible to add support for React Native in a similar way.

I have no experience with React Native, but if someone wants to do some exploring here, I'll be happy to provide guidance and review PR's.

Stefan-Hanke commented 6 years ago

The other UI stuff is coupled to React. How do you plan to proceed?

chrisheninger commented 6 years ago

@Stefan-Hanke I'd assume the UI stuff will continue to be coupled directly with React for now– and anyone implementing React Native/Vue/Angular will be responsible for bringing their own UI components.

@nicolodavis I gave this a shot about a month back– I'm pretty sure the only things that need changes are converting the divs to Views, handling the CSS imports + debug UI, and adding an example using RN (probably with create-react-native-app + Expo.io)

I'm not sure what my schedule is like in the next couple weeks– I'll get going on something but if anyone else reads this and wants to take a stab at it please do!

nicolodavis commented 6 years ago

We'll need to have parallel implementations in React Native / Vue / Angular. However, that doesn't mean they can't share code. @Stefan-Hanke proposes sharing SVG code in https://github.com/google/boardgame.io/pull/111, which I think is a good idea.

I think the UI components are the easy bit. The Debug pane is going to be harder. React Native doesn't really need one (or could use a pretty watered down version), but I think it will need to be rewritten completely for Angular and Vue (they can start out without having one, of course).

shirakaba commented 6 years ago

What's the status of RN integration now? I'll be attempting a RN project with this soon, and would be willing to contribute if anything's missing.

That, and/or TypeScript support.

jstacoder commented 6 years ago

i think everything is in master, just waiting on release 0.22 to get cut and it will be available on npm

nicolodavis commented 6 years ago

It is already on NPM. Would welcome some testers though (I haven't checked if it works correctly).

shirakaba commented 6 years ago

Would welcome some testers though (I haven't checked if it works correctly).

Seems to work!

screen shot 2018-05-03 at 22 39 26

This screenshot is actually my port of the react-native tic-tac-toe example to TypeScript. It's made as a non-Expo app, for some variety. The port is not quite ready to show yet, as I first need to figure out how to distribute the TypeScript declarations (I have no idea how to get them to co-operate with rollup bundles).

vdfdev commented 6 years ago

That looks amazing, great work!

jstacoder commented 6 years ago

yea, doing import { Client } from 'boardgame.io/react-native' even works on exposnack.io now

shirakaba commented 6 years ago

Wow, I'll have to try that out sometime.