DoclerLabs / hexMachina

Releases, issues, documentation, website of hexMachina, framework written in Haxe
http://hexmachina.org
MIT License
44 stars 8 forks source link

Should support running many times the same app in one HTML page #214

Closed aliokan closed 7 years ago

aliokan commented 7 years ago

We should be able to run app in some kind of sandbox to prevent all conflicts if we run the same application many times in the same HTML page.

aliokan commented 7 years ago

now with 0.16.0 is working with XmlReader + Preprocessor to set a unique context name at runtime, like:

var uuid = GUID.uuid();
var uniqueContextName = "context-" + uuid;

var preprocessor = new Preprocessor();
preprocessor.addProperty( "contextName", uniqueContextName );

var source = XmlReader.getXml("configuration/context.xml").toString();
var xml = Xml.parse( preprocessor.parse( source ) );
var contextParser = new ApplicationXMLParser();
contextParser.parse(_applicationAssembler, xml);
<root name="${contextName}">
…

Should add a solution with XmlCompiler.

aliokan commented 7 years ago

Support since 0.28.0 : https://github.com/DoclerLabs/hexMachina/releases/tag/0.28.0

var code = StaticFlowCompiler.compile( assembler, "context/flow/dsl.flow" );
code.execute();

var clonedCode = code.clone( new ApplicationAssembler() );
clonedCode.execute();

Assert.isInstanceOf( code.locator.instance, MockClassWithoutArgument );
Assert.isInstanceOf( clonedCode.locator.instance, MockClassWithoutArgument );

Assert.notEquals( code.locator.instance, clonedCode.locator.instance );