Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lang.Class in Javascript

I'm trying to develop an Gnome Shell extension using GJS(Gnome Javascript), however, I came across the Lang library (I think it is a library, if not correct me). But I can't find any resources about it on the web.

In the code it looks something like this:

const Lang = imports.lang;

const ObjectA = new Lang.Class({ ... });

Where can I find some documentation about it? Is it a Gnome lib? A Mozilla lib?

like image 972
Ángel Araya Avatar asked Mar 19 '14 06:03

Ángel Araya


1 Answers

It's a built-in module of gjs -- see modules/lang.js. It includes two main things: bind() (a helper to make "this" point to the logical object in closures) and Class, which basically implements a class in a language that does not have the concept of classes... It would be hard to work with GObject (a class-based object system) without this.

like image 192
Jussi Kukkonen Avatar answered Oct 21 '22 07:10

Jussi Kukkonen