Coder Social home page Coder Social logo

vaadin-enhancedjavascript's Introduction

EnhacedJavaScript for vaadin

What is EnhancedJavaScript for vaadin?

EnhancedJavaScriptComponent is a drop-in replacement for AbstractJavaScriptComponent. It supports transmission of state deltas between the server and client rather than transmitting the entire state object. This reduces the payload size for each component update request/response. It also incorporates and extends the features of JavascriptComponentPlus - allowing you to set deferred variables to be transmitted from client to server.

Workflow

To package and install the addon, run the following commands. This will run tests and install the resulting addon jar in your local Maven repository cache.

mvn package -DskipTests=true
mvn install

To run tests only, run "mvn test".

To run the test UI in interactive mode run UIRunner.main() (found under the test directory).

Debugging client side code

  • run "mvn vaadin:run-codeserver" on a separate console while the test UI is running
  • activate Super Dev Mode in the debug window of the application

Project setup

For use in Maven-based projects add the following dependency to your application's pom file:

<dependency>
  <groupId>com.emuanalytics</groupId>
  <artifactId>vaadin-enhancedjavascript</artifactId>
  <version>0.1.1</version>
</dependency>

You will also need to include the widgetset in your project by including it in your own application-specific widget set:

<inherits name="com.emuanalytics.vaadin.enhancedjavascript.EnhancedJavascriptWidgetset" />

Usage

Your Javascript component should extend com.emuanalytics.vaadin.enhancedjavascript.EnhancedJavaScriptComponent rather than Vaadin's supplied AbstractJavaScriptComponent.

Your Javascript state class should extend com.emuanalytics.vaadin.enhancedjavascript.EnhancedJavaScriptComponentState rather than Vaadin's supplied AbstractJavaScriptComponentState.

Other than this, creating a component with EnhancedJavascript is exactly the same as creating an AbstractJavaScriptComponent-based component.

###Extra features An additional JavaScript method is provided on your connector object - getStateDeltas(). This is designed to be used in your onStateChange method and returns an object containing just the deltas (the properties that have been updated) in response to the state change event.

To set a deferred variable, call the setDeferredVariable(variableName, value, immediateFlag) method of your connector. This works in the same way as the method provided by JavascriptComponentPlus with the added feature of allowing immediate transmission of the change event to the server.

Demo

Look in the test directory for a sample component.

Acknowledgements

This addon is based in part on JavascriptComponentPlus from Sebastian Rothbucher.

The testing framework is supported by Addon Test Helpers from Matti Tahvonen.

vaadin-enhancedjavascript's People

Contributors

robinsummerhill avatar

Watchers

James Cloos avatar  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.