Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. client
  5. isWorkerInitialized

spark.client.isWorkerInitialized

function isWorkerInitialized(): boolean

Check if the Spark worker has been initialized.

Returns true after the first call to useSpark(). Useful for conditional setup or debugging.

Returns

boolean– True if worker is initialized and running

Examples

// Set up RPC handlers only if worker exists
if (isWorkerInitialized()) {
  const state = getGlobalState();
  console.log('Worker state:', state);
}
Previous
getGlobalState
Next
requestHotReload