Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 07:43
    bigopon commented #669
  • 07:42
    bigopon commented #668
  • Nov 26 13:24
    DanieleRosada opened #670
  • Nov 26 13:24
    DanieleRosada opened #669
  • Nov 26 13:24
    DanieleRosada opened #668
  • Nov 25 03:06
    CLAassistant commented #9
  • Nov 25 03:05
    dependabot[bot] labeled #9
  • Nov 25 03:05
    dependabot[bot] opened #9
  • Nov 25 03:05

    dependabot[bot] on npm_and_yarn

    chore(deps): bump highlight.js … (compare)

  • Nov 24 23:48
    CLAassistant commented #54
  • Nov 24 23:48
    dependabot[bot] labeled #54
  • Nov 24 23:48
    dependabot[bot] opened #54
  • Nov 24 23:48

    dependabot[bot] on npm_and_yarn

    chore(deps): bump highlight.js … (compare)

  • Nov 24 23:42
    CLAassistant commented #37
  • Nov 24 23:42
    dependabot[bot] labeled #37
  • Nov 24 23:42
    dependabot[bot] opened #37
  • Nov 24 23:42

    dependabot[bot] on npm_and_yarn

    chore(deps): bump highlight.js … (compare)

  • Nov 24 23:42
    CLAassistant commented #189
  • Nov 24 23:42
    dependabot[bot] labeled #189
  • Nov 24 23:42
    dependabot[bot] opened #189
bigopon
@bigopon
@xenoterracide DI in v2 is an enhancement of v1 DI. and is like v1, it can be used anywhere
v2 is aimed to retain 90% of app code. And if you touch lower level API, then there will be work needed, otherwise, it's just plain old your app and your business logic
in anyway, feel free to open a discourse topic to ask more about DI
Caleb Cushing
@xenoterracide
already the error messages seem better than tsyringe, which is the other decent DI I found for node
bigopon
@bigopon
or join Discord forum for a quick chat, we are migrating the community there
Caleb Cushing
@xenoterracide
it was like, hey you did something stupid... on this line, actually useful
bigopon
@bigopon
nice, maybe share that small details, but nice quality of life too? on discourse? we lack those chats, and would love them :smile:
Caleb Cushing
@xenoterracide
I'm going to try to write a decorator, @registry like in tsyringe, I wonder if you guys would be interested
bigopon
@bigopon
can you give an example
Caleb Cushing
@xenoterracide
import { singleton } from '@aurelia/kernel';
import { LoggingWinston } from '@google-cloud/logging-winston';
import { instanceCachingFactory, registry } from 'tsyringe';
import winston, { format, Logger, LoggerOptions, transports } from 'winston';

export const LoggerDefault = 'defaultLogger';
export const LoggerTypeOrm = 'typeormLogger';
export const LoggerSecurity = 'securityLogger';
export const LoggerSecurityChild = 'childSecurityLogger';

@registry([
  { token: LoggerDefault, useFactory: instanceCachingFactory(createDefaultLogger) },
  { token: LoggerTypeOrm, useFactory: instanceCachingFactory(createTypeOrmLogger) },
  { token: LoggerSecurity, useFactory: instanceCachingFactory(createSecurityLogger) },
])
export class LoggerProvider {}

export function createDefaultLogger(): Logger {
  const config: LoggerOptions =
    process.env['NODE_ENV'] === 'development' ? devConfig() : serverConfig();

  return winston.loggers.add(LoggerDefault, config);
}

function createTypeOrmLogger(): Logger {
  const config: LoggerOptions =
    process.env['NODE_ENV'] === 'development' ? devConfig() : serverConfig();

  return winston.loggers.add(LoggerTypeOrm, config);
}

function createSecurityLogger(): Logger {
  const config: LoggerOptions =
    process.env['NODE_ENV'] === 'development' ? devConfig() : googleConfig();
  return winston.loggers.add(LoggerSecurity, config);
}

function devConfig(): LoggerOptions {
  const console = new transports.Console({
    level: process.env.LOG_LEVEL || 'info',
    debugStdout: true,
    format: format.combine(format.cli(), format.splat(), format.simple()),
  });
  return {
    transports: [console],
    exceptionHandlers: [console],
  };
}

function googleConfig(): LoggerOptions {
  return {
    transports: [
      new LoggingWinston({
        projectId: process.env.GOOGLE_SERVICE_ACCOUNT_PROJECT_ID,
        credentials: {
          client_email: process.env.GOOGLE_SERVICE_ACCOUNT_CLIENT_EMAIL!,
          private_key: process.env.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY!,
        },
      }),
    ],
  };
}

function serverConfig(): LoggerOptions {
  return {
    transports: [
      new transports.Console({
        level: process.env.LOG_LEVEL || 'info',
        debugStdout: true,
        format: format.combine(format.splat(), format.simple()),
      }),
    ],
  };
}
from what I can tell for most of our use cases it's basically Registration.callback, Registration.instance, Registration.somethinglikeToken
etc
basically all the functionality is already there, this is just some syntactic sugar
bigopon
@bigopon
that looks pretty nice, maybe a discourse topic please? :smile:
please help sharing, our community has too many dark matter devs, no one shares anything :smile:
Caleb Cushing
@xenoterracide
yeah sure, I'll hop on over to discourse later
yeah, I've just been ramping up on the frontend
again
bigopon
@bigopon
:+1:
Pedro Silva
@pmanu93

@bigopon

@pmanu93 it's beause of value.bind="true"

No. Turns out its because I have a click event in the li that is wrapping those elements. (I use that to toggle a div inside the li which contains the checkbox above)..

Luis Lebolo
@lebolo

If I have a custom element and use the DOM remove() function on it, will the unbind() and detached() lifecycle hooks on its view-model be called? For example

const myCustomElement = document.querySelector('#myCustomElement');
myCustomElement.remove()

I'm trying to track down whether I'm doing this incorrectly or if I should not expect those lifecycle hooks to be called when an element is removed from the DOM in this way.

I can confirm that those lifecycle hooks get called when the element is in a route and I navigate away from the route.

Logan AAA Flag
@logan_aaaflag_gitlab
Hey bit of a long shot but I have a @processContent(...) decorator within which I'm trying to register a custom component (like this example in the docs https://aurelia.io/docs/templating/custom-elements#decorators-for-customizing-aurelia-custom-element-processing sandbox link https://codesandbox.io/s/p7wo71qrzj?from-embed )
But when I call resources.registerElement( "icon-list-item", instruction.type["viewFactory"].resources.getElement("icon-list-item") );
I get an error ERROR [templating] TypeError: Cannot read property 'resources' of undefined
Does anyone know under what circumstances the viewFactory can be undefined in a @processContent(...) handler?
Caleb Cushing
@xenoterracide
ARGH... this %#$@$@! bug, I'm gonna lose all my hair
now what makes Reflect.decorate happen...
donald-slagle
@donald-slagle
Is it possible to limit a route parameter? I've got a top level route that can take an id and I'd like to limit that route to just integers. I'm integrating vanity URLs for affiliates and that top level route is catching everything. I know in ASP.NET I can do something like [HttpGet("{id:int}")]. Having something like that would take care of it or being able to define a regex for a route param would also take care of it.
Caleb Cushing
@xenoterracide
@donald-slagle I thought you could, but I can't find anything that suggests anything other than these https://aurelia.io/docs/fundamentals/cheat-sheet#routing
I would totally love a regex pattern matching router in 2, you should open a ticket or something
donald-slagle
@donald-slagle
Yeah it would be a great feature. I think I'm going to have to convert my current route that takes an int Id to a query string param so my vanity URL can work. Only issue is I have to push a mobile app update to keep that int Id working properly but backwards compatibility for people that haven't upgraded will stop working. Might have to keep digging for a solution.
Caleb Cushing
@xenoterracide
anyone know how to actually build the aurelia 2 repo? going to try hacking out a patch...
Caleb Cushing
@xenoterracide
damn, working on this repo is a pita
Chris Matzenbach
@cmatzenbach
hey, i have a quick question - how does one go about testing modals, since they won't have an inView property as they are called directly from a a view-model (at least ours are, via functions tied to buttons in the view and whatnot)
or i guess in the aurelia terminology they are called dialogs. how do you test dialogs?
Chris Matzenbach
@cmatzenbach
i'm using mocha/chai/sinon, by the way
bigopon
@bigopon
@CapnKernel you can create a simple element that invoke the modal
@xenoterracide what pita? Installation time? Or other issues?
@donald-slagle it was planned at some point, but was never acted pn. Probably it has more chance landing on v2. Can you help open a ticket in https://github.com/aurelia/aurelia
@lebolo it wont be called. But theres a way to make aurelia invoke the lifecycle by just adding removing the element via aurelia web component. Maybe try that?
@pmanu93 by default, Aurelia invokes preventDefault on all listener if the event handler does not return true. So in the click handler of li element, you just need to return true
Luis Lebolo
@lebolo
@bigopon: thanks!
NightWulfe
@NightWulfe

Hello. I used the information in the manual for setting up a simple aurelia with webpack, without using aurelia-cli. When I run npx webpack to build the project, I get this error:

ERROR in multi aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-loader-entry aurelia-boostrapper Module not found: Error: Can't resolve 'aurelia-webpack-plugin/runtime/empty-entry' in '' @ multi-aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-load-entry aurelia-bootstrapper main[0]1
I've tried installing aurelia-pal-browser and aurelia-pal-nodejs with no change. Any ideas?

Jameson Strocsher
@jamesond
@rafatpc Did you happen to figure out your issues with a rest parameter must be of an array type for aurelia-dependency-injection?
NightWulfe
@NightWulfe
No one can offer any ideas as to what may be causing my error?
Pedro Silva
@pmanu93
@bigopon :Thanks!
Luis Lebolo
@lebolo

Is there a limit to the number of global resources I can register? I have a resources/index.ts that looks like

import {FrameworkConfiguration, PLATFORM} from 'aurelia-framework';

export function configure(config: FrameworkConfiguration) {
  config.globalResources([
    PLATFORM.moduleName('./elements/resource-1/resource-1'),
    PLATFORM.moduleName('./elements/resource-2/resource-2'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/resource-3'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-4/resource-4'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-5/resource-5'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-6/resource-6'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-7/resource-7'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-8/resource-8'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-9/resource-9'),
    PLATFORM.moduleName('./elements/resource-2/resource-3/inputs/resource-10/resource-10'),
  ]);
}

But when I inject ViewResources into my app.ts constructor and print it out, I get

elements:
  compose: HtmlBehaviorResource {elementName: "compose", attributeName: null, attributeDefaultBindingMode: undefined, liftsContent: false, targetShadowDOM: false, …}
  resource-2: HtmlBehaviorResource {elementName: "resource-2", attributeName: null, attributeDefaultBindingMode: undefined, liftsContent: false, targetShadowDOM: false, …}
  resource-1: HtmlBehaviorResource {elementName: "resource-1", attributeName: null, attributeDefaultBindingMode: undefined, liftsContent: false, targetShadowDOM: false, …}
  resource-4: HtmlBehaviorResource {elementName: "resource-4", attributeName: null, attributeDefaultBindingMode: undefined, liftsContent: false, targetShadowDOM: false, …}
  resource-3: HtmlBehaviorResource {elementName: "resource-3", attributeName: null, attributeDefaultBindingMode: undefined, liftsContent: false, targetShadowDOM: false, …}
  router-view: HtmlBehaviorResource {elementName: "router-view", attributeName: null, attributeDefaultBindingMode: undefined, liftsContent: false, targetShadowDOM: false, …}

I confirmed that they all exist and can be found. Weirdly, if I comment out the resource-4 line in index.ts then ViewResources will just show resources 1, 2, 3 & 5 instead. Is there a limit?

NightWulfe
@NightWulfe
Yesterday I had a problem where webpack was reporting an error about being unable to resolve empty-entry when doing npx webpack. Either no one was willing to help, or they just didn't know the issue. I finally figured it out, so I'll post it here in the off chance anyone else runs into the problem: Make sure there are periods prefixed to the resolve extensions in your webpack config.