Trouble migrating from Au1 to Au2 where certain technical APIs are being utilized

  1. For @noView:

    Finally, it would appear that @noView and @processContent have changed as well. I haven’t been able to migrate the following use case (i.e., the specific combination of the two decorators below):

    @noView()
    @processContent(false)
    export class TsiDxButton() {
        ...
    }
    

    As you noted, @noView can now be achieved with template: null in the custom element options, though it’s a good thing that we can create a decorator @noView to specify that.


  1. For @processContent(false):
    Thanks for explaining the intention. It can be achieved in v2 via the data property on the instruction of the custom element instance
    import { resolve, IInstruction } from 'aurelia';
    import { HydrateElementInstruction } from '@aurelia/template-compiler';
    
    @processContent((node, platform, instructionData) => {
      instructionData.template = node.querySelector('dx-template');
    })
    export class DxSelectBox {
      constructor() {
        const { data } = resolve(IInstruction) as HydrateElementInstruction;
        const template = data.template;
        // do your stuff here
      }  
    }
    
    As you noted you’ll delete the <dx-template> after the extraction during the compilation, I think the above should suffice.

  1. For the post itself:

    … How do achieve this scenario in Au2? This was explicitly covered in Rob’s course, and I use it in our Au1 application with great success!

    Thanks for the long detailed post, (and others). It may give some more good idea where in the doc we can improve, maybe a course is needed again. cc @dwaynecharrington .

1 Like