These are chat archives for canjs/canjs

May 2018
May 29 2018 08:37
noob qu: I want to create a constant regex for re-use in derived classes - what 'type' do I set for a regex?
May 29 2018 08:41


Here are some points about Can.js that i noticed since i started working with it.

1. Route blocking issue
Earlier we discussed a solution to block the routing.
But eventually none seemed to solve our problem.
Which was to conditionally block the routing when the user presses the browser back button.

Although I'm not a fan of the angular ecosystem. Here's how they approach it in angularjs.

$scope.$on('$locationChangeStart', function(event, next, current) {
    if ($scope.form.$invalid) {

Maybe someting like this can be implemented in Can.js?

2. The kind of syntax seen below is very confusing to me.
Part of the proposition to solve our routing issue contained this.

get x() {
    return this.y.get();

Maybe the syntax for watching entire objects should be a little easier.

3. React vs Stache
I'd Like to know how Stache compares to React in terms of rendering speed.

Justin Meyer
May 29 2018 11:57
Thanks for the feedback. Please create an issue.
I don’t believe that the angular solution actually solves the problem. Does it actually prevent the back button from changing the url?
Justin Meyer
May 29 2018 12:02

The syntax for watching entire objects was listening for “change” events. Supporting this caused all sorts of performance problems and added lots of code. It was removed for this relatively simple alternative pattern.

Also, generally, you shouldn’t listen to entire objects anyway. This case was an exception, but when we had change, people would us it for things they shouldn’t.

Btw, that syntax is just ES5 getters. The .get() is just a way to clone an object
May 29 2018 12:29
Thanks for the reply
Gregg Roemhildt
May 29 2018 14:52
Has anyone used any tools to generate a pdf from a canjs component?
May 29 2018 15:59
nope...but if you find one, pls tell us ;)
Gregg Roemhildt
May 29 2018 16:00
Justin Meyer
May 29 2018 16:10
@nmingneau please let me know if the Angular solution actually solves the back-button problem.
If it does, some of my assumptions about what the browser does are wrong
popstate isn't cancelable: ... so I'm not sure angular solves it for this case