jeudi 29 avril 2021

Decoupling 'game' logic from React/front end frameworks

I was recently working on implementing battleship into react. My hang-up with getting the project done was that I really want to make the logic of battleship framework-agnostic. I don't want to have to write the 'game' in react. I want to write the game in JS, and have react handle the UI. But I'd love the ability to implement the game into another UI framework, or even a CLI.

Is this thinking butting heads with react as a framework? Or should I write some sort of event handler (observer pattern, etc.) that updates the state in react to integrate the game?

I've seen a lot of 'tutorials' about doing things like, making tic-tac toe in react, but they all tie the game logic itself INTO react. Am I just stuck in an OOP or MVC thought pattern (and not thinking in 'flux')? Does anyone have any thoughts on decoupling logic like this from react?

Aucun commentaire:

Enregistrer un commentaire