New Total.js version 2.5

Tue Apr 18 2017 10:40:39 GMT+0200 (Central European Summer Time), Peter Širka

New Total.js version 2.5

It's the best time to switch to Total.js. I can say that the framework is a professional tool for all web developers and their companies. Today it's Your last chance to buy Total.js Premium Account at 30% discount. Buy the premium with chat support now and start your business with Total.js platform, we'll change your view of web development in the next days.

What's new?

  • supports WebSocket DEFLATE compression algorithm
  • replaced EventEmitter with custom implementation in the framework core (this step increased performance)
  • rewritten handling of static files
  • improved overall performance about 2-5%
  • improved components, components now support groups
  • improved loading of framework dependencies
  • improved view rendering
  • Total.js apps can be handled via Passenger web server
  • improved responses
  • improved requests processing
  • improved WebSocket performance
  • improved a memory consumption for GraphicsMagick and ImageMagick (great news for weaker VPS)
  • and many small fixes and improvements


New global aliases

Events:

  • ON(name, fn) alias for F.on()
  • OFF(name, [fn]) alias for F.removeListener(name, fn) or F.removeAllListeners(name)
  • EMIT(name, arg1, arg..N) alias for F.emit()
ON('ready', function() {
   console.log('Framework is loaded.');
});

Schemas:

  • $GET(schema, [options], callback) alias for GETSCHEMA(name).get()
  • $QUERY(schema, [options], callback) alias for GETSCHEMA(name).query()
  • $WORKFLOW(schema, name, [options], callback) alias for GETSCHEMA(name).workflow2()
  • $TRANSFORM(schema, name, [options], callback) alias for GETSCHEMA(name).transform2()
  • $OPERTION(schema, name, [options], callback) alias for GETSCHEMA(name).transform2()
  • $MAKE(schema, model, [filter], [callback], [novalidate], [argument]) alias for GETSCHEMA(name).make()
$QUERY('User', { page: 1 }, function(err, response) {
   console.log(err, response);
});

Other:

  • WAIT alias for U.wait()

A new alternative of schema declaration

An small example:

NEWSCHEMA('User').make(function(schema) {

    schema.setSave(function($) {
        // $.error
        // $.model
        // $.options
        // $.callback
        // $.controller
    });

    schema.addWorkflow('name', function($) {
        // $.error
        // $.model
        // $.options
        // $.callback
        // $.controller
    });

});

Debugging of Total.js application

I have added a debug logging into the framework. You can enable it via allow-debug : true in a config file or by passing options to http method:

require('total.js').http('release', { debug: true });

Example of output:

2017-04-08 23:06:19 ---------> init
2017-04-08 23:06:19 ---------> HTTP listening
2017-04-08 23:06:19 ---------> clear temporary
2017-04-08 23:06:19 ---------> clear temporary (done)
2017-04-08 23:06:19 ---------> load dependencies 2x
2017-04-08 23:06:19 ---------> install definition#requests
2017-04-08 23:06:19 ---------> install controller#default
2017-04-08 23:06:19 ---------> load dependencies 2x (done)
2017-04-08 23:06:19 ---------> done
====================================================
PID         : 45660
Node.js     : v7.8.0
Total.js    : v2.5.0-14
OS          : darwin 16.5.0
====================================================
Name        : Total.js
Version     : 1.0.0
Author      : You company name
Date        : 2017-04-08 23:06:19
Mode        : release
====================================================

http://127.0.0.1:8000/
  • the framework creates /usage.log file when it is initialized
  • at every service interval the file /usage.log is updated
  • created for critical situations

Scheduler

Now scheduler can be cleared via F.clearSchedule().

var schedule = F.schedule('12:00', '1 day', NOOP);

// Remove scheduler
F.clearSchedule(schedule);

Components

The components mechanism supports groups to render all components from the group:

// A component declaration
// New field "group":
exports.group = 'name';
<div>
    @{components('groupname', { custom: 'Settings (optional)' });
</div>

This mechanism can extend your web applications (e.g. Total.js Messenger uses this mechanism).

Consolidated config names

IMPORTANT: don't worry all older names will be work the next 3 versions, so you have time for replacing older values. I have updated more than 60 projects because of that.

mail.smtp           : old name
mail-smtp           : new name

mail.smtp.options   : old name
mail-smtp-options   : new name

mail.address.from   : old name
mail-address-from   : new name

mail.address.reply  : old name
mail-address-reply  : new name

mail.address.copy   : old name
mail-address-copy   : new name

Easy way to change SMTP server

I have added a new method for easy changing of SMTP server with a check via Mail.try(). More information in documentation.

F.useSMTP('hostname', { user: '', password: '' });

Deferred functions

[ Not-cached .................... slowest (214 ms)
[ Cached ....................... +72.0% fastest (60 ms)
// A helper function
function something_async(controller, callback) {
    callback(controller);
}

// Worse performance
function some_controller_action_nocached() {
    var controller = this;
    something_async(controller, function(controller) {
        controller.plain('OK');
    });
}

// +70% better performance
function some_controller_action_cached() {
    var controller = this;
    something_async(controller, cached);
}

function cached(controller) {
    controller.plain('OK');
}

How it works?
Framework automatically parses all functions function DEFER and saves them to the helper variable.

// RAW CODE
function some_controller_action() {
    var controller = this;
    something_async(controller, function DEFER(controller) {
        controller.plain('OK');
    });
}
// RESULT
function some_controller_action() {
    var controller = this;
    something_async(controller, F.temporary.defer.D1936555);
}

With new version is also coming a new product Total.js Flow (I hope next week) and better functionality (coming soon) for Total.js Eshop, Messenger, SuperAdmin, Dashboard, etc..


Tags

Follow us

Latest blogs
Flow v6 is here!
Thu Mar 07 2019 11:53:54 GMT+0100 (Central European Standard Time)
A critical security fix
Wed Feb 13 2019 22:15:39 GMT+0100 (Central European Standard Time)
New release: Total.js v3.2
Wed Feb 13 2019 22:14:39 GMT+0100 (Central European Standard Time)
Total.js Wiki v2
Fri Jan 04 2019 22:15:01 GMT+0100 (Central European Standard Time)
Total Year 2018
Thu Jan 03 2019 21:14:00 GMT+0100 (Central European Standard Time)

Latest comments
Nice tip
Mauro Junior
Thu Sep 20 2018 21:41:02 GMT+0200 (Central European Summer Time)
Not only for Total.js. You can communicate with different websocket servers.
Peter Širka
Mon Apr 23 2018 20:08:20 GMT+0200 (Central European Summer Time)
Marko: you need to create a buffer with this codepage and write byte-to-byte string. I recommend ...
Peter Širka
Mon Apr 23 2018 20:06:21 GMT+0200 (Central European Summer Time)
Is WEBSOCKETCLIENT only for internal ws connections between totaljs apps?
Stelios Stephanua
Fri Mar 16 2018 06:04:22 GMT+0100 (Central European Standard Time)
Total.js is amazing! ;)
Leonardo Hessel
Tue Dec 19 2017 19:51:15 GMT+0100 (Central European Standard Time)

Pixabay


Read more

Flow v6 is here!

News: We have released a new version of Flow. This version brings great new features and UI improvements.

Thu Mar 07 2019 11:53:54 GMT+0100 (Central European Standard Time)
A critical security fix

News: We were notified about the critical security bug in Total.js framework. Read a prevention.

Wed Feb 13 2019 22:15:39 GMT+0100 (Central European Standard Time)
New release: Total.js v3.2

News: This new release brings a critical security fix and small new improvements. Update Total.js now.

Wed Feb 13 2019 22:14:39 GMT+0100 (Central European Standard Time)
Total.js Wiki v2

Products: I have released a new version of Total.js Wiki. New version brings new improvements.

Fri Jan 04 2019 22:15:01 GMT+0100 (Central European Standard Time)
Total Year 2018

Business: Last year was perfect for Total.js platform. Total.js platform grows up and it has great results.

Thu Jan 03 2019 21:14:00 GMT+0100 (Central European Standard Time)
Total.js Code Editor v1

Products: Try our real-time collaboration tool for Total Developers. Code Editor offers great features for development.

Fri Dec 07 2018 22:55:13 GMT+0100 (Central European Standard Time)