Coder Social home page Coder Social logo

crux-counter's Introduction

Crux Counter Example

The Crux Counter example is a simple multi-platform application that calls a cloud-hosted API.

It makes HTTP requests to a shared global counter hosted at https://crux-counter.fly.dev, incrementing or decrementing the counter value.

The server also has an endpoint for Server Sent Events (https://crux-counter.fly.dev/sse), which signals when changes are made to the global counter value — so that when you update the counter in one client, all the other clients will update too.

We have included an example of a Server Sent Events capability, which uses the core's ability to stream responses from the shell.

screenshots

Notes:

  1. Please make sure you have the following rust targets installed (there is a rust-toolchain.toml in the root directory of this repo, so you should be able to type rustup target list --installed, in or below the root directory, and these targets will be installed if they are not already present).

    aarch64-apple-darwin
    aarch64-apple-ios
    aarch64-apple-ios-sim
    aarch64-linux-android
    wasm32-unknown-unknown
    x86_64-apple-ios
  2. This example currently depends on the pnpm package manager when generating types for TypeScript. We are currently revisiting the type generation for foreign types and so this requirement will probably go, but for now, please install pnpm.

Rust shared library

  1. Make sure the core builds

    cargo build --package shared
  2. Generate the shared types for your client applications

    cargo build --package shared_types

Web app — Yew

If you don't have it already, install the trunk CLI tool:

brew install trunk

To build and run the Yew web app:

cd web-yew
trunk serve

Web app — Leptos

If you don't have it already, install the trunk CLI tool:

brew install trunk

To build and run the Leptos web app:

cd web-leptos
trunk serve

Web app — Dioxus

If you don't have it already, install the dx CLI tool:

cargo install dioxus-cli

To build and run the [Dioxus]https://dioxuslabs.com/) web app:

cd web-dioxus
dx serve

Web app — NextJS (React)

To build and run the NextJS web app:

cd web-nextjs
pnpm install
pnpm dev

Notes:

On Windows if you get "ℹ️ Installing wasm-pack" it does not work. You can solve it by installing it manually from: https://rustwasm.github.io/wasm-pack/installer/

Mobile app — iOS

You will need XCode, which you can get in the Mac AppStore

cd iOS
open CounterApp.xcodeproj

You should be able to press "Play" to start the app in the simulator, or on an iPhone.

Notes:

  • You may encounter this error:

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    

    If this happens, then you need to install the Command Line Tools For Xcode.

Mobile app — Android

Open the Android folder in Android Studio. If the build is successful, you should be able to press "Play" to start the app in the simulator.

Notes:

  • The Android Studio build might fail for a couple of known reasons:
    • A linker-wrapper.sh script failure
      Ensure you have Python installed and your PATH
    • NDK is not installed
      Install this via Android Studio --> Settings --> Appearance and Behaviour --> System Settings --> Select the "SDK Tools" tab, select "NDK (side by side)" and press Apply to install
  • If Android studio fails to install git, you can set the path to your git binary (e.g. the homebrew one) in the preferences under Version Control > Git

Tauri

To build and run the Tauri app:

cd tauri
pnpm install
pnpm tauri dev

crux-counter's People

Contributors

kauderk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.