Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orion-dev] embeddededitor and require.js



On Fri, Dec 2, 2011 at 12:09 PM, Felipe Heidrich <Felipe_Heidrich@xxxxxxxxxx> wrote:
Hi John,

We changed all the editor code (textview and editor) to be regular requirejs components. We still support the non-requirejs case, but the users needs to include orion/textview/global.js for that to work. The embeddededitor is non-requirejs sample, the /examples/textview/demo.html is pure requirejs.

Ok, by comparing the two examples, I've figure out what had me confused.  

The API design and the older non-requirejs examples use x.y.z() eg orion.editor.Editor(). The newer requirejs examples use mSomeLocal.z(), eg mTextModel.TextModel().

(I think using the redirection, eg mTextModel, makes the system harder to understand. For every object/function you have to first translate the local before you can understand the call. It's fine if the local was local, but it's really a file-level object closed over in the file, often hundreds of lines from the call.)

What I decided to create an orionAssembly, a module which takes all of the modules I need and exports 'orion' object like the original API design.

(In creating this file I learned that the file names are inconsistent with the objects. For example, orion.textview.keyBindings.js exports orion.textview.KeyBindings. These inconsistencies (which I regret I also see in my code) make the code harder to work with.)

On the plus side, simply by merging the properties exported by of all the files resulted in the objects I wanted.  Then I can import 'orionAssembly' as |orion| and use orion.editor or orion.textview as before.

 

You said that you already have require() defined (thus orion/textview/global.js breaks you). Why is require() defined for you ? Do you have requirejs loaded ? almond maybe (https://github.com/jrburke/almond ) ?


require is defined because I use require.js in my code.
 
Or is this what you need ? https://bugs.eclipse.org/bugs/show_bug.cgi?id=365388

I'm all set now, thanks! 


Felipe




From: John J Barton <johnjbarton@xxxxxxxxxxxxxxx>
To: Orion developer discussions <orion-dev@xxxxxxxxxxx>
Date: 12/01/2011 10:57 PM
Subject: [orion-dev] embeddededitor and require.js
Sent by: orion-dev-bounces@xxxxxxxxxxx





I'm trying to update my embeddededitor to the 0.4 master version.
Among the changes, the newer version uses define() and it uses shim
window.require() to allow the files with define() in them to be loaded
with script tags.

However my code uses require() so the shim breaks me.

Obviously the solution is to remove the script tags and use require.
But I don't know the dependency tree: does anyone know easily what
needs to be called in? I can always use binary search.

jjb
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev




_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev



Back to the top