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:
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..