alepha@docs:~/framework/docs/reference/primitives$
cat $context.md | pretty
1 min read

#$context

#Import

typescript
1import { $context } from "alepha";

#Overview

Get Alepha instance and current service from the current context.

It can only be used inside $primitive functions.

ts
 1import { $context, Alepha } from "alepha"; 2  3const $hello = () => { 4  const { alepha, service, module } = $context(); 5  6  // alepha - alepha instance 7  // service - class which is creating this primitive, this is NOT the instance but the service definition 8  // module - module definition, if any 9 10  return {};11}12 13class MyService {14  hello = $hello();15}16 17const alepha = new Alepha().with(MyService);