Giter Club home page Giter Club logo

liveweb's Introduction

LiveWeb

test workflow

LiveWeb is a server side rendered web application framework for Smalltalk. It is based on Zinc HTTP server and WebSockets.

The components live on the server and can send updates to clients through the web socket.

Quick start guide

Try docker examples

You can try the examples in a docker with

docker run -p 8080:8080 antitadex/liveweb-examples

and opening examples: http://localhost:8080/examples/clock (and counter, wordle).

Installation

 Metacello new
   repository: 'github://tatut/LiveWeb/src';
   baseline: 'LiveWeb';
   load.

Creating a page and component.

The main endpoint is an instance of LWPage subclass. The page will create the head (optional) and body (required) components for each page render. The page will register itself with a random UUID so the client can connect to it.

Creating a simple counter component.

LWPage subclass: #CounterPage.

CounterPage >> body: args [
  ^ CounterComponent new
]

The create the component.

LWComponent subclass: #CounterComponent
  instanceVariableNames: 'counter'.

CounterComponent >> initialize [
  super initialize.
  counter := 0
]

CounterComponent >> renderOn: h [
  h div: { #id->'myBody' } with: [
    h button: { #onclick -> [ self counter: counter - 1] } with: '-';
      div: counter asString;
      button: { #onclick -> [ self counter: counter + 1] } with: '+'
  ]
]

CounterComponent >> counter: newValue [
  counter := newValue.
  self changed "this causes the component to rerender"
]

Then you need to register the page into the Zinc server delegate.

ZnServer default delegate
  map: #counter
  to: [:req | CounterPage new value: req ].

See the LiveWeb-Examples package for more elaborate examples and examples of using the styling package.

liveweb's People

Contributors

pegesund avatar tatut 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.