Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 14 21:13
    greenkeeper[bot] labeled #5378
  • Oct 14 21:12
    greenkeeper[bot] opened #5378
  • Oct 14 21:12

    greenkeeper[bot] on can-simple-map-4.3.3

    fix(package): update can-simple… (compare)

  • Oct 14 20:19
    greenkeeper[bot] labeled #5377
  • Oct 14 20:19
    greenkeeper[bot] opened #5377
  • Oct 14 20:19

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Oct 14 20:18
    greenkeeper[bot] labeled #5376
  • Oct 14 20:18
    greenkeeper[bot] opened #5376
  • Oct 14 20:18

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Oct 14 14:43
    greenkeeper[bot] closed #5373
  • Oct 14 14:43

    greenkeeper[bot] on can-deep-observable-1.0.1

    (compare)

  • Oct 14 14:42

    m-mujica on update-deep-observable

    (compare)

  • Oct 14 14:42

    m-mujica on master

    Update can-deep-observable to l… Merge pull request #5374 from c… (compare)

  • Oct 14 14:42
    m-mujica closed #5374
  • Oct 14 14:42
    m-mujica closed #5365
  • Oct 14 14:09
    f-ricci starred canjs/canjs
  • Oct 14 13:55
    greenkeeper[bot] commented #5375
  • Oct 14 13:55

    greenkeeper[bot] on core-js-3.3.2

    chore(package): update core-js … (compare)

  • Oct 14 10:51
    m-mujica review_requested #5374
  • Oct 14 07:43
    rjgotten commented #5358
Justin Meyer
@justinbmeyer
I don’t believe that the angular solution actually solves the problem. Does it actually prevent the back button from changing the url?

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
nmingneau
@nmingneau
Thanks for the reply
Gregg Roemhildt
@roemhildtg
Has anyone used any tools to generate a pdf from a canjs component?
Julian
@pYr0x
nope...but if you find one, pls tell us ;)
Gregg Roemhildt
@roemhildtg
:smirk:
Justin Meyer
@justinbmeyer
@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: https://stackoverflow.com/questions/32432296/is-it-possible-to-e-preventdefault-in-window-onpopstate ... so I'm not sure angular solves it for this case
nmingneau
@nmingneau

@justinbmeyer

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.page}.${routing.subpage}`);
    if (this.workInProgress && handlerResult) {
        this.preventRoutingDialog.translations = handlerResult;
        this.preventRoutingDialogVisible = true;
    } else {
        this.assign(newRoute);
    }
}

For routing that goes out of the spa we use this

window.onbeforeunload = () => {
  if (routeHandlerConfig[routing.page][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.

Ngaosathe
@ThekhoN
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(
  can.set.props.boolean("complete"),
  can.set.props.id("id"),
  can.set.props.sort("sort")
);

const todoStore = can.fixture.store([
  {
    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 }
});
Julian
@pYr0x
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
@justinbmeyer
@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.
Justin Meyer
@justinbmeyer

Hey @/all folks! I'm working on adding a Model / Service layer overview section to CanJS's Technology Overview page:

https://canjs.github.io/next/doc/guides/technology-overview.html#Observablesandtheservicelayer

If anyone has time to read through and make suggestions, it would be greatly appreciated. You can add comments here:

https://docs.google.com/document/d/1M4nLJ-njfY0jtQFKKcbiplhVVc0kJozCJE55XsacvBg/edit#heading=h.5w1dq3a9aft4

image.png
nmingneau
@nmingneau
@justinbmeyer @chasenlehara I created an issue concerning the route cancelling: canjs/can-route#169.
Chasen Le Hara
@chasenlehara
Thanks @nmingneau!
Gregg Roemhildt
@roemhildtg

Hey guys, so I defined a custom callback in stache using can-stache-callbacks like:

callbacks.attr('props', function(el, attrData) {
    const key = el.getAttribute('props');
    const data = attrData.scope.find(key);
    const viewModel = canViewModel(el);
    if (viewModel && data) {
        canReflect.assign(viewModel, data);
    } else {
        // dev-remove-start
        // eslint-disable-next-line
        console.warn('could not find viewmodel or data props for ' + key);
        // dev-remove-end
    }
});

but its running after the view model is initiated. Is it possible to set it up so that the props get passed like normal properties and the values will be available to the viewmodel immediately after being inserted?

Jeroen Cornelissen
@jeroencornelissen
I’m seeing this error recently Uncaught TypeError: Cannot read property 'Symbol(can.getSchema)' of undefined at Object.getSchema (schema.js:110) Is this a known issue or is it something at our side :fire: ?
Jeroen Cornelissen
@jeroencornelissen
Hmm, nvm. Something is pushing undefined in a list.
Chasen Le Hara
@chasenlehara
@roemhildtg I’m having a hard time understanding what your goal is. 😅 Is it to have the VM not be initialized with the initial values? Or that you control when the props get set?
Gregg Roemhildt
@roemhildtg
@chasenlehara My goal is simply to pass props to the component, but as an object. I guess its a temporary workaround until the stache implements the spread operator.
Chasen Le Hara
@chasenlehara
Ahh gotcha @roemhildtg. One trick would be to do something like <my-comp this:from="vmObject" /> to set the this of my-comp to the vmObject
Justin Meyer
@justinbmeyer
@chasenlehara does that work?
I don't think it does
Chasen Le Hara
@chasenlehara
Mohamed Cherif Bouchelaghem
@cherifGsoul
@roemhildtg what are you trying to acheive? getting a prop value in the scope?
RyanMilligan
@RyanMilligan

Hi! We have a page (using Can 3) where the user can edit multiple objects in a list and then click Save to save all of them. Currently we loop through the list to find any items that are dirty and call save() on those, but that ends up firing a lot of separate requests to the middle tier which a) can't all be done in one transaction like we'd like them to be, and b) is sending potentially a lot of requests to our database at the same time and causing deadlocks, since they all edit the same table.

What I'd really like is a save function on List that serializes the objects inside an array, but the existing save pipeline seems very specific to passing single instances. Is there any pre-built solution to this, or would we have to craft our own request and figure out ourselves how to get the live objects updated (e.g., with final ids that come back from the server)?

Mohamed Cherif Bouchelaghem
@cherifGsoul
@roemhildtg is this what you want to acheive? https://jsbin.com/facatur/edit?html,js,console,output cc @chasenlehara
Chasen Le Hara
@chasenlehara
@RyanMilligan I think adding your own save() method on your List makes sense; then you could call save() on the individual objects sequentially, or whatever makes sense for your server.
That way, I don’t think you’d have to serialize them first and then figure out updating the “live” objects later…
RyanMilligan
@RyanMilligan
I can't call them sequentially though, I want to run it through the existing behavior pipeline but end up just calling the server once, with an array containing all the instances that are being saved. The current pipeline seems not to support that, since it will e.g. try to find an id property on the list in order to put it in an instance store, which it will later fail to find it in.
Chasen Le Hara
@chasenlehara
Ohh, so your server does support updating multiple objects in a single request?
RyanMilligan
@RyanMilligan
Yes, or at least it can very easily. I actually currently receive a single object and then wrap it in a fake array for processing, so it's a very small amount of work to just have it use the array it was already passed.
Justin Meyer
@justinbmeyer
I've just manually added a save function
to the list prototype
RyanMilligan
@RyanMilligan
And it goes through the existing behavior pipeline like a normal save? Like, real-time to make sure everything gets sorted appropriately, the instances get hydrated so the ids that come back from the server get put in the appropriate places, etc?
with the data as it comes back
DefList.extend({
  ..
  save(){
    MAKE_REQUEST().then(function(updatedData){
      updatedData.forEach( (record)=> connection.updateInstance( record ) )
    })
  }
})
RyanMilligan
@RyanMilligan
Ok, gotcha. So you're saying, craft my own request to submit the save, then call into the pipeline with the data that comes back?