Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Publish/Subscribe in SmartClientJS

    Simple question, is there support for publish and subscribe in the JS only version of SmartClient? When searching for this in the forum, I see only posts related to SmartGWT.

    In my earlier days of SC development, I updated other components from other components and now I would like to do it cleaner by publishing events and subscribing to them.

    #2
    Using publish/subscribe doesn't imply you are "do[ing] it cleaner" - for most UIs, using pubsub-style communication between components actually just makes for unnecessary complexity (in other words, a mess!).

    The exception is an extremely large application that has multiple configurations where some parts of the UI may be present or not present based on what the customer has bought - in this case, direct references between UI components can become unwieldy because of the number of null checks and the difficulty of testing that there are no inappropriate direct references.

    *If* you are in this situation, you could consider building a pubsub system based on SmartClient's Class.observe() capability (a few dozen lines of code will do it).

    Comment


      #3
      Suppose I have a screen with two grids: employees and jobs. The jobs grid depends on the employees grid: as soon as you select a different employee, the jobs grid needs to refreshed.

      In a "pub/sub" mechanism, the employees grid would simply fire an "employee-selected" event (to the whole application) with the employee's ID as its parameter and the jobs grid would be listening to "employee-selected" events and respond by refreshing its data.

      In my earlier development days, I fired this jobs "refresh" from within the employees grid. This worked, but introduces "tight coupling" between the employees and jobs grid. It would be nice if I can get around that. Is that doable (in reasonable amount of code)?

      It's not a disaster if it can't be done, but it would be nicer (in my opinion) if it can.

      Comment


        #4
        We're familiar with elementary publish-subscribe :)

        You should re-read our previous response - we're making a more sophisticated argument about whether it's actually worth it in a given scenario.

        Comment


          #5
          LOL! Yeah, of course you know what publish-subscribe is, but maybe others not. I didn't when I started SmartClient development.

          Re-reading your response, you're right that it probably makes more sense in a situation where a customer can buy custom UI components, which is not the case in my situation. But I do have to deal with users having different privileges. Some of them might not see certain UI components, others do.

          I will try to do without pub-sub for now, but I would be interested (also, with the idea of becoming a "better programmer") to know how it is done in SmartClient.

          Comment

          Working...
          X