Custom Language Autocomplete Async

This is kind of on the same level as this thread: Async

I am implementing my own Language and the autocomplete values I will be getting with an ajax call. I am having trouble figuring out how I may update my language after its instantiated with autocomplete values, or even if that is possible?

// Initial empty completions
const completions ={
	autocomplete: completeFromList([]),

const language = function () {
	return new LanguageSupport(newLanguage, [completions]);

Since completions is an extension into LanguageSupport i thought i might be able to Compartment it but i don’t know how to update the language? Is there a way?


Yes, putting the part of the configuration that you want to dynamically update in a compartment is how you do this. That includes the language (which is also just an extension).

Thanks! I just want to clarify. I would have to dispatch an update of the compartment of a language to the view? There is no way to update a compartment of autocomplete (which is an extension passed into LanguageSupport) to the language? You only can do that on view correct?


Yes. Languages and other extensions are immutable objects. All state changes are done by dispatching to the view.

1 Like