Last active
January 18, 2018 17:03
-
-
Save villeilkkala/e45f1632e8b7ad4d3ca10ef968b1ef1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(providedTemplate) => { | |
if (!providedTemplate) { | |
console.error("LocalPartition instancer did not receive the template entity to instance"); | |
return null; | |
} | |
const localUserPartitionId = this[Resource.createDerivedId]("localUserPartition"); | |
const partitionURI = Valaa.Partition.createPartitionURI("valaa-local:", localUserPartitionId); | |
const alreadyActive = Valaa.Partition.tryPartitionConnection(partitionURI); | |
if (alreadyActive) { | |
const localPartitionResource = Valaa.Resource.getActiveResource(localUserPartitionId); | |
return localPartitionResource; | |
} | |
const initializationProcess = Valaa.Partition.acquirePartitionConnection(partitionURI); | |
return initializationProcess.then(connection => { | |
let localProject = Valaa.Resource.getActiveResource(localUserPartitionId); | |
if (!localProject) { | |
const ProjectTemplate = providedTemplate; | |
localProject = new ProjectTemplate({ | |
id: localUserPartitionId, | |
owner: null, | |
partitionAuthorityURI: "valaa-local:", | |
name: ProjectTemplate[Valaa.name] + " [local instance]", | |
}); | |
} | |
return localProject; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment