These are chat archives for canjs/canjs

May 2018
May 30 2018 07:41


Indeed, I think the only way to stop the browser from routing to a previous page outside of your spa is window.onbeforeunload.
But I just wanted to point out that I like the fact that angularjs has an event that triggers before every routing action inside the spa.
At the moment we wrote a wrapper function that gets called instead of directly updating the router viewModel.

routeHandler(newRoute) {
    this.preventRoutingDialog.newRoute = newRoute;
    const handlerResult = _invoke(routeHandlerConfig, `${}.${routing.subpage}`);
    if (this.workInProgress && handlerResult) {
        this.preventRoutingDialog.translations = handlerResult;
        this.preventRoutingDialogVisible = true;
    } else {

For routing that goes out of the spa we use this

window.onbeforeunload = () => {
  if (routeHandlerConfig[][routing.subpage] && routing.workInProgress) {
    return true;

Also, do you have any information regarding the react and stache comparison?
Since I don't know how stache works internally I was wondering if the virtual dom use of react makes a difference in terms of performance to stache.

May 30 2018 10:05
hi..i'm learning canjs for an older project. what is a practical usage of can.set.Algebra?
Looking at the todoMVC example,
const todoAlgebra = new can.set.Algebra(

const todoStore =[
    id: 5,
    name: "mow lawn",
    complete: false
    id: 6, 
    name: "dishes",
    complete: true
    id: 7,
    name: "learn canjs",
    complete: false
], todoAlgebra);
and then again,
const Todo = can.DefineMap.extend({
  id: "number",
  name: "string",
  complete: { type: "boolean", default: false }
May 30 2018 11:27
it takes sorting and filtering
if you are using caching
or realtime behaviour
if you have a list and make a new request to the server that updates that list, set.Algebra will sort or filter the new list with the given configuration of the set logic
Justin Meyer
May 30 2018 14:23
@nmingneau CanJS performs diffs on data vs a rendered virtual DOM. Also, it's able to see updates on the scale of individual {{magicTags}}
the end result is that CanJS is a bit slower on initial render, but tends to be faster on updates to "pieces" of a much larger page
@nmingneau regarding that feature of angular ... it's a nice feature. @chasenlehara is working on some minor improvements to can-route right now. Can you create an issue and we'll see if we can add it.