Optional
namespace: string = 'reactium'The namespace for the annotations. The namespace is searched for as @
Optional
type: "sync" | "async" = 'async'The type of the processor, either 'async' or 'sync'.
import { Hook, annotationsFactory, Processor } from '@atomic-reactor/reactium-sdk-core';
// Define some example annotations
const examples = `
@reactium foo.bar Some content here.
@reactium Reactium.State.description global state object
@reactium Reactium.State.Tools collection of useful components <MyDemo> [file:example.md]
@reactium example.multiple.mds [file:example.md] [file:example2.md]
`;
// Create an annotations processor
const annotations = annotationsFactory('reactium', 'async');
// Register a processor to prepend 'test1: ' to the content
Hook.registerSync('@reactium', (registry) => {
const processor: Processor<string> = {
id: 'testProcessor1',
processor: async (content) => {
return 'test1: ' + content;
},
};
registry.register('testProcessor1', processor);
});
// Use the annotations processor to process the example annotations
annotations(examples).then((obj) => {
console.log(op.get(obj, 'foo.bar')); // Logs 'test1: Some content here.'
console.log(op.get(obj, 'Reactium.State.description')); // Logs 'test1: global state object'
console.log(op.get(obj, 'Reactium.State.Tools')); // Logs 'test1: collection of useful components <MyDemo> [file:example.md]'
});
Factory function to create an annotations processor.